Skip to content

Commit

Permalink
Resolved #466 - Remove wordcloud2.js from dependencies in code
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Aug 29, 2024
1 parent 611cd25 commit 7bbcaeb
Show file tree
Hide file tree
Showing 19 changed files with 3 additions and 111 deletions.
2 changes: 0 additions & 2 deletions examples/bar-vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../node_modules/survey-core/survey.i18n.js"></script>
<script src="../packages/survey.analytics.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions examples/chart_text.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/custom-gauge.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/custom_vis.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../node_modules/survey-core/survey.i18n.js"></script>
<script src="../packages/survey.analytics.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions examples/histogram.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/matrix-one-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/matrixdropdown-grouped.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/matrixdropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/matrixes.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/multi_lang.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
<script src="https://cdn.plot.ly/plotly-locale-ru-latest.js"></script>
<script src="https://cdn.plot.ly/plotly-2.8.3.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../node_modules/survey-core/survey.i18n.js"></script>
<script src="../packages/survey.analytics.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions examples/ranking.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/state_in_localstorage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions examples/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../node_modules/survey-core/survey.i18n.js"></script>
<script src="../packages/survey.analytics.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions examples/summarytest.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script src="https://unpkg.com/plotly.js-dist-min/plotly.min.js"></script>

<script src="https://unpkg.com/[email protected]/src/wordcloud2.js"></script>

<script src="../node_modules/survey-core/survey.core.js"></script>
<script src="../packages/survey.analytics.js"></script>
</head>
Expand Down
28 changes: 2 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@
"muuri": "^0.8.0",
"plotly.js-dist-min": "^2.28.0",
"survey-core": "latest",
"tabulator-tables": "4.8.4",
"wordcloud": "^1.2.2"
"tabulator-tables": "4.8.4"
},
"devDependencies": {
"@types/jest": "^26.0.24",
"@types/jquery": "3.3.29",
"@types/lodash": "4.14.121",
"@types/node": "7.0.4",
"@types/wordcloud": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"ajv": "6.12.3",
Expand Down
46 changes: 0 additions & 46 deletions src/wordcloud/wordcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { VisualizationManager } from "../visualizationManager";
import { textHelper } from "./stopwords/index";
import { DocumentHelper } from "../utils";
import { localization } from "../localizationManager";
// import WordCloudLib from "wordcloud";
import { WordCloudWidget, defaultOptions } from "./widget";

export class WordCloudAdapter {
Expand All @@ -27,51 +26,6 @@ export class WordCloudAdapter {
return this._wordcloud;
}

private async createWordCloud2(node: HTMLElement) {
const data = await this.model.getCalculatedValues();
const colors = this.model.getColors();
const canvasNode = <HTMLCanvasElement>(
DocumentHelper.createElement("canvas", "")
);
const emptyTextNode = <HTMLElement>DocumentHelper.createElement("p", "", {
innerText: localization.getString("noResults"),
});

if (data.length === 0) {
node.appendChild(emptyTextNode);
return;
}

node.appendChild(canvasNode);

const config = {
list: data,
weightFactor: WordCloudAdapter.weightFactor,
abortThreshold: WordCloudAdapter.abortThreshold,
drawOutOfBound: WordCloudAdapter.drawOutOfBound,
shrinkToFit: WordCloudAdapter.shrinkToFit,
fontFamily: "Segoe UI Bold, sans-serif",
color: (word: string, weight: number) => {
return this.model.getRandomColor();
},
rotateRatio: 0.5,
rotationSteps: 2,
backgroundColor: this.model.backgroundColor,
click: function (item: any) {
// eslint-disable-next-line no-console
console.log(item[0] + ": " + item[1]);
},
};

const options = {
canvas: canvasNode,
config
};
WordCloudAdapter.onWordcloudCreating.fire(this.model, options);
// this._wordcloud = WordCloudLib(options.canvas, options.config as any);
return this._wordcloud;
}

public async create(element: HTMLElement): Promise<any> {
const data = await this.model.getCalculatedValues();
const colors = this.model.getColors();
Expand Down
6 changes: 0 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ module.exports = function (options) {
commonjs: "survey-core",
amd: "survey-core",
},
wordcloud: {
root: "WordCloud",
commonjs2: "wordcloud",
commonjs: "wordcloud",
amd: "wordcloud",
},
"plotly.js-dist-min": {
root: "Plotly",
commonjs2: "plotly.js-dist-min",
Expand Down

0 comments on commit 7bbcaeb

Please sign in to comment.