chartjs-plugin-chart2music 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.js +10 -18
- package/dist/plugin.mjs +10 -18
- package/package.json +19 -19
package/dist/plugin.js
CHANGED
|
@@ -75,6 +75,7 @@ var chartjs2music = (function (c2mChart) {
|
|
|
75
75
|
return { groups, data: result };
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
const chartStates = new Map();
|
|
78
79
|
const chartjs_c2m_converter = {
|
|
79
80
|
bar: "bar",
|
|
80
81
|
line: "line",
|
|
@@ -271,8 +272,8 @@ var chartjs2music = (function (c2mChart) {
|
|
|
271
272
|
});
|
|
272
273
|
}
|
|
273
274
|
else {
|
|
274
|
-
const
|
|
275
|
-
|
|
275
|
+
const { visible_groups } = chartStates.get(chart);
|
|
276
|
+
visible_groups.forEach((datasetIndex) => {
|
|
276
277
|
highlightElements.push({
|
|
277
278
|
datasetIndex,
|
|
278
279
|
index
|
|
@@ -350,19 +351,10 @@ var chartjs2music = (function (c2mChart) {
|
|
|
350
351
|
c2mOptions.audioEngine = options.audioEngine;
|
|
351
352
|
}
|
|
352
353
|
const { err, data: c2m } = c2mChart(c2mOptions);
|
|
353
|
-
chart
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
chartjs2music: {
|
|
358
|
-
...chart.config.options?.plugins?.chartjs2music,
|
|
359
|
-
internal: {
|
|
360
|
-
c2m,
|
|
361
|
-
visible_groups: groups?.map((g, i) => i)
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
};
|
|
354
|
+
chartStates.set(chart, {
|
|
355
|
+
c2m,
|
|
356
|
+
visible_groups: groups?.map((g, i) => i)
|
|
357
|
+
});
|
|
366
358
|
// /* istanbul-ignore-next */
|
|
367
359
|
if (err) {
|
|
368
360
|
options.errorCallback?.(err);
|
|
@@ -372,7 +364,7 @@ var chartjs2music = (function (c2mChart) {
|
|
|
372
364
|
if (!args.mode) {
|
|
373
365
|
return;
|
|
374
366
|
}
|
|
375
|
-
const ref = chart
|
|
367
|
+
const { c2m: ref, visible_groups } = chartStates.get(chart);
|
|
376
368
|
if (!ref) {
|
|
377
369
|
return;
|
|
378
370
|
}
|
|
@@ -382,7 +374,7 @@ var chartjs2music = (function (c2mChart) {
|
|
|
382
374
|
}
|
|
383
375
|
if (args.mode === "hide") {
|
|
384
376
|
const err = ref.setCategoryVisibility(groups[args.index], false);
|
|
385
|
-
|
|
377
|
+
visible_groups.splice(args.index, 1);
|
|
386
378
|
if (err) {
|
|
387
379
|
console.error(err);
|
|
388
380
|
}
|
|
@@ -390,7 +382,7 @@ var chartjs2music = (function (c2mChart) {
|
|
|
390
382
|
}
|
|
391
383
|
if (args.mode === "show") {
|
|
392
384
|
const err = ref.setCategoryVisibility(groups[args.index], true);
|
|
393
|
-
|
|
385
|
+
visible_groups.push(args.index);
|
|
394
386
|
if (err) {
|
|
395
387
|
console.error(err);
|
|
396
388
|
}
|
package/dist/plugin.mjs
CHANGED
|
@@ -74,6 +74,7 @@ const processBoxData = (data) => {
|
|
|
74
74
|
return { groups, data: result };
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
const chartStates = new Map();
|
|
77
78
|
const chartjs_c2m_converter = {
|
|
78
79
|
bar: "bar",
|
|
79
80
|
line: "line",
|
|
@@ -270,8 +271,8 @@ const plugin = {
|
|
|
270
271
|
});
|
|
271
272
|
}
|
|
272
273
|
else {
|
|
273
|
-
const
|
|
274
|
-
|
|
274
|
+
const { visible_groups } = chartStates.get(chart);
|
|
275
|
+
visible_groups.forEach((datasetIndex) => {
|
|
275
276
|
highlightElements.push({
|
|
276
277
|
datasetIndex,
|
|
277
278
|
index
|
|
@@ -349,19 +350,10 @@ const plugin = {
|
|
|
349
350
|
c2mOptions.audioEngine = options.audioEngine;
|
|
350
351
|
}
|
|
351
352
|
const { err, data: c2m } = c2mChart(c2mOptions);
|
|
352
|
-
chart
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
chartjs2music: {
|
|
357
|
-
...chart.config.options?.plugins?.chartjs2music,
|
|
358
|
-
internal: {
|
|
359
|
-
c2m,
|
|
360
|
-
visible_groups: groups?.map((g, i) => i)
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
};
|
|
353
|
+
chartStates.set(chart, {
|
|
354
|
+
c2m,
|
|
355
|
+
visible_groups: groups?.map((g, i) => i)
|
|
356
|
+
});
|
|
365
357
|
// /* istanbul-ignore-next */
|
|
366
358
|
if (err) {
|
|
367
359
|
options.errorCallback?.(err);
|
|
@@ -371,7 +363,7 @@ const plugin = {
|
|
|
371
363
|
if (!args.mode) {
|
|
372
364
|
return;
|
|
373
365
|
}
|
|
374
|
-
const ref = chart
|
|
366
|
+
const { c2m: ref, visible_groups } = chartStates.get(chart);
|
|
375
367
|
if (!ref) {
|
|
376
368
|
return;
|
|
377
369
|
}
|
|
@@ -381,7 +373,7 @@ const plugin = {
|
|
|
381
373
|
}
|
|
382
374
|
if (args.mode === "hide") {
|
|
383
375
|
const err = ref.setCategoryVisibility(groups[args.index], false);
|
|
384
|
-
|
|
376
|
+
visible_groups.splice(args.index, 1);
|
|
385
377
|
if (err) {
|
|
386
378
|
console.error(err);
|
|
387
379
|
}
|
|
@@ -389,7 +381,7 @@ const plugin = {
|
|
|
389
381
|
}
|
|
390
382
|
if (args.mode === "show") {
|
|
391
383
|
const err = ref.setCategoryVisibility(groups[args.index], true);
|
|
392
|
-
|
|
384
|
+
visible_groups.push(args.index);
|
|
393
385
|
if (err) {
|
|
394
386
|
console.error(err);
|
|
395
387
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chartjs-plugin-chart2music",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Chart.js plugin for Chart2Music. Turns chart.js charts into music so the blind can hear data.",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -36,25 +36,25 @@
|
|
|
36
36
|
"clean": "rimraf dist coverage"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@rollup/plugin-typescript": "
|
|
40
|
-
"@sgratzl/chartjs-chart-boxplot": "
|
|
41
|
-
"@types/jest": "
|
|
42
|
-
"canvas": "
|
|
43
|
-
"chartjs-chart-wordcloud": "
|
|
44
|
-
"chartjs-plugin-a11y-legend": "
|
|
45
|
-
"cross-env": "
|
|
46
|
-
"depcheck": "
|
|
47
|
-
"jest": "
|
|
48
|
-
"jest-environment-jsdom": "
|
|
49
|
-
"rimraf": "
|
|
50
|
-
"rollup": "
|
|
51
|
-
"ts-jest": "
|
|
52
|
-
"tslib": "
|
|
53
|
-
"typescript": "
|
|
54
|
-
"vite": "
|
|
39
|
+
"@rollup/plugin-typescript": "11.1.4",
|
|
40
|
+
"@sgratzl/chartjs-chart-boxplot": "4.2.5",
|
|
41
|
+
"@types/jest": "29.5.5",
|
|
42
|
+
"canvas": "2.11.2",
|
|
43
|
+
"chartjs-chart-wordcloud": "4.3.0",
|
|
44
|
+
"chartjs-plugin-a11y-legend": "0.1.0",
|
|
45
|
+
"cross-env": "7.0.3",
|
|
46
|
+
"depcheck": "1.4.6",
|
|
47
|
+
"jest": "29.7.0",
|
|
48
|
+
"jest-environment-jsdom": "29.7.0",
|
|
49
|
+
"rimraf": "5.0.5",
|
|
50
|
+
"rollup": "3.29.4",
|
|
51
|
+
"ts-jest": "29.1.1",
|
|
52
|
+
"tslib": "2.6.2",
|
|
53
|
+
"typescript": "5.2.2",
|
|
54
|
+
"vite": "4.4.9"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"chart.js": "
|
|
58
|
-
"chart2music": "
|
|
57
|
+
"chart.js": "4.4.0",
|
|
58
|
+
"chart2music": "1.12.2"
|
|
59
59
|
}
|
|
60
60
|
}
|