chartjs-plugin-chart2music 0.6.0 → 0.6.1

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/README.md CHANGED
@@ -77,6 +77,15 @@ new Chart(canvasElement, {
77
77
  });
78
78
  ```
79
79
 
80
+ If you are using TypeScript, replace the first 4 lines with this:
81
+ ```ts
82
+ import {Chart, type ChartTypeRegistry} from "chart.js/auto";
83
+ import chartjs2music from "chartjs-plugin-chart2music";
84
+
85
+ new Chart(canvasElement, {
86
+ type: "bar" as keyof ChartTypeRegistry,
87
+ ```
88
+
80
89
  ## Supported features
81
90
 
82
91
  This plugin is currently in beta, so not all of the chart.js features are currently supported.
@@ -88,6 +97,7 @@ A quick list of chart.js features we currently support includes:
88
97
  * Axes options: `title`, `min`, `max`, `type="linear"`, `type="logarithmic"`.
89
98
  * Chart title
90
99
  * Most data structures (not including `parsing` or non-standard axes identifiers)
100
+ * Dataset visibility (when you show/hide a category from the legend)
91
101
 
92
102
  Note that visual-specific chart features are ignored. This includes things like color, padding, line thickness, etc.
93
103
 
@@ -97,7 +107,6 @@ Things we plan to support in the future:
97
107
  * Complex `parsing` options for data
98
108
  * Date/Time support for axes
99
109
  * Subtitle
100
- * Dataset visibility (when you show/hide a category from the legend)
101
110
  * Radar charts
102
111
  * Custom formatting for axis tick values
103
112
 
@@ -109,7 +109,7 @@ define(['chart2music'], (function (c2mChart) { 'use strict';
109
109
  };
110
110
  const generateAxisInfo = (chartAxisInfo, chart) => {
111
111
  const axis = {};
112
- if (chartAxisInfo?.min) {
112
+ if (chartAxisInfo?.min !== undefined) {
113
113
  if (typeof chartAxisInfo.min === "string") {
114
114
  axis.minimum = chart.data.labels.indexOf(chartAxisInfo.min);
115
115
  }
@@ -117,7 +117,7 @@ define(['chart2music'], (function (c2mChart) { 'use strict';
117
117
  axis.minimum = chartAxisInfo.min;
118
118
  }
119
119
  }
120
- if (chartAxisInfo?.max) {
120
+ if (chartAxisInfo?.max !== undefined) {
121
121
  if (typeof chartAxisInfo.max === "string") {
122
122
  axis.maximum = chart.data.labels.indexOf(chartAxisInfo.max);
123
123
  }
@@ -138,13 +138,16 @@ define(['chart2music'], (function (c2mChart) { 'use strict';
138
138
  const axes = {
139
139
  x: {
140
140
  ...generateAxisInfo(chart.options?.scales?.x, chart),
141
- valueLabels: chart.data.labels.slice(0)
142
141
  },
143
142
  y: {
143
+ format: (value) => value.toLocaleString(),
144
144
  ...generateAxisInfo(chart.options?.scales?.y, chart),
145
- format: (value) => value.toLocaleString()
146
145
  }
147
146
  };
147
+ const xAxisValueLabels = chart.data.labels.slice(0);
148
+ if (xAxisValueLabels.length > 0) {
149
+ axes.x.valueLabels = xAxisValueLabels;
150
+ }
148
151
  return axes;
149
152
  };
150
153
  const whichDataStructure = (data) => {
package/dist/plugin.cjs CHANGED
@@ -149,14 +149,14 @@ var processChartType = function processChartType(chart) {
149
149
  var generateAxisInfo = function generateAxisInfo(chartAxisInfo, chart) {
150
150
  var _chartAxisInfo$title;
151
151
  var axis = {};
152
- if (chartAxisInfo !== null && chartAxisInfo !== void 0 && chartAxisInfo.min) {
152
+ if ((chartAxisInfo === null || chartAxisInfo === void 0 ? void 0 : chartAxisInfo.min) !== undefined) {
153
153
  if (typeof chartAxisInfo.min === "string") {
154
154
  axis.minimum = chart.data.labels.indexOf(chartAxisInfo.min);
155
155
  } else {
156
156
  axis.minimum = chartAxisInfo.min;
157
157
  }
158
158
  }
159
- if (chartAxisInfo !== null && chartAxisInfo !== void 0 && chartAxisInfo.max) {
159
+ if ((chartAxisInfo === null || chartAxisInfo === void 0 ? void 0 : chartAxisInfo.max) !== undefined) {
160
160
  if (typeof chartAxisInfo.max === "string") {
161
161
  axis.maximum = chart.data.labels.indexOf(chartAxisInfo.max);
162
162
  } else {
@@ -175,15 +175,17 @@ var generateAxisInfo = function generateAxisInfo(chartAxisInfo, chart) {
175
175
  var generateAxes = function generateAxes(chart) {
176
176
  var _chart$options, _chart$options2;
177
177
  var axes = {
178
- x: _objectSpread(_objectSpread({}, generateAxisInfo((_chart$options = chart.options) === null || _chart$options === void 0 || (_chart$options = _chart$options.scales) === null || _chart$options === void 0 ? void 0 : _chart$options.x, chart)), {}, {
179
- valueLabels: chart.data.labels.slice(0)
180
- }),
181
- y: _objectSpread(_objectSpread({}, generateAxisInfo((_chart$options2 = chart.options) === null || _chart$options2 === void 0 || (_chart$options2 = _chart$options2.scales) === null || _chart$options2 === void 0 ? void 0 : _chart$options2.y, chart)), {}, {
178
+ x: _objectSpread({}, generateAxisInfo((_chart$options = chart.options) === null || _chart$options === void 0 || (_chart$options = _chart$options.scales) === null || _chart$options === void 0 ? void 0 : _chart$options.x, chart)),
179
+ y: _objectSpread({
182
180
  format: function format(value) {
183
181
  return value.toLocaleString();
184
182
  }
185
- })
183
+ }, generateAxisInfo((_chart$options2 = chart.options) === null || _chart$options2 === void 0 || (_chart$options2 = _chart$options2.scales) === null || _chart$options2 === void 0 ? void 0 : _chart$options2.y, chart))
186
184
  };
185
+ var xAxisValueLabels = chart.data.labels.slice(0);
186
+ if (xAxisValueLabels.length > 0) {
187
+ axes.x.valueLabels = xAxisValueLabels;
188
+ }
187
189
  return axes;
188
190
  };
189
191
  var whichDataStructure = function whichDataStructure(data) {
package/dist/plugin.js CHANGED
@@ -110,7 +110,7 @@ var chartjs2music = (function (c2mChart) {
110
110
  };
111
111
  const generateAxisInfo = (chartAxisInfo, chart) => {
112
112
  const axis = {};
113
- if (chartAxisInfo?.min) {
113
+ if (chartAxisInfo?.min !== undefined) {
114
114
  if (typeof chartAxisInfo.min === "string") {
115
115
  axis.minimum = chart.data.labels.indexOf(chartAxisInfo.min);
116
116
  }
@@ -118,7 +118,7 @@ var chartjs2music = (function (c2mChart) {
118
118
  axis.minimum = chartAxisInfo.min;
119
119
  }
120
120
  }
121
- if (chartAxisInfo?.max) {
121
+ if (chartAxisInfo?.max !== undefined) {
122
122
  if (typeof chartAxisInfo.max === "string") {
123
123
  axis.maximum = chart.data.labels.indexOf(chartAxisInfo.max);
124
124
  }
@@ -139,13 +139,16 @@ var chartjs2music = (function (c2mChart) {
139
139
  const axes = {
140
140
  x: {
141
141
  ...generateAxisInfo(chart.options?.scales?.x, chart),
142
- valueLabels: chart.data.labels.slice(0)
143
142
  },
144
143
  y: {
144
+ format: (value) => value.toLocaleString(),
145
145
  ...generateAxisInfo(chart.options?.scales?.y, chart),
146
- format: (value) => value.toLocaleString()
147
146
  }
148
147
  };
148
+ const xAxisValueLabels = chart.data.labels.slice(0);
149
+ if (xAxisValueLabels.length > 0) {
150
+ axes.x.valueLabels = xAxisValueLabels;
151
+ }
149
152
  return axes;
150
153
  };
151
154
  const whichDataStructure = (data) => {
package/dist/plugin.mjs CHANGED
@@ -109,7 +109,7 @@ const processChartType = (chart) => {
109
109
  };
110
110
  const generateAxisInfo = (chartAxisInfo, chart) => {
111
111
  const axis = {};
112
- if (chartAxisInfo?.min) {
112
+ if (chartAxisInfo?.min !== undefined) {
113
113
  if (typeof chartAxisInfo.min === "string") {
114
114
  axis.minimum = chart.data.labels.indexOf(chartAxisInfo.min);
115
115
  }
@@ -117,7 +117,7 @@ const generateAxisInfo = (chartAxisInfo, chart) => {
117
117
  axis.minimum = chartAxisInfo.min;
118
118
  }
119
119
  }
120
- if (chartAxisInfo?.max) {
120
+ if (chartAxisInfo?.max !== undefined) {
121
121
  if (typeof chartAxisInfo.max === "string") {
122
122
  axis.maximum = chart.data.labels.indexOf(chartAxisInfo.max);
123
123
  }
@@ -138,13 +138,16 @@ const generateAxes = (chart) => {
138
138
  const axes = {
139
139
  x: {
140
140
  ...generateAxisInfo(chart.options?.scales?.x, chart),
141
- valueLabels: chart.data.labels.slice(0)
142
141
  },
143
142
  y: {
143
+ format: (value) => value.toLocaleString(),
144
144
  ...generateAxisInfo(chart.options?.scales?.y, chart),
145
- format: (value) => value.toLocaleString()
146
145
  }
147
146
  };
147
+ const xAxisValueLabels = chart.data.labels.slice(0);
148
+ if (xAxisValueLabels.length > 0) {
149
+ axes.x.valueLabels = xAxisValueLabels;
150
+ }
148
151
  return axes;
149
152
  };
150
153
  const whichDataStructure = (data) => {
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "chartjs-plugin-chart2music",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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",
7
7
  "module": "dist/plugin.mjs",
8
8
  "exports": {
9
- "import": "./dist/plugin.mjs",
9
+ "import": {
10
+ "default": "./dist/plugin.mjs",
11
+ "types": "./dist/plugin.d.ts"
12
+ },
10
13
  "require": "./dist/plugin.cjs"
11
14
  },
12
15
  "types": "dist/plugin.d.ts",
@@ -40,29 +43,32 @@
40
43
  "prepack": "npm run clean && npm run build"
41
44
  },
42
45
  "devDependencies": {
43
- "@babel/cli": "7.25.6",
44
- "@babel/core": "7.25.2",
45
- "@babel/plugin-transform-modules-commonjs": "7.24.8",
46
- "@babel/preset-env": "7.25.4",
47
- "@rollup/plugin-typescript": "12.1.0",
48
- "@sgratzl/chartjs-chart-boxplot": "4.4.2",
49
- "@types/jest": "29.5.13",
50
- "canvas": "2.11.2",
51
- "chartjs-chart-wordcloud": "4.4.2",
52
- "chartjs-plugin-a11y-legend": "0.1.2",
46
+ "@babel/cli": "7.27.0",
47
+ "@babel/core": "7.26.10",
48
+ "@babel/plugin-transform-modules-commonjs": "7.26.3",
49
+ "@babel/preset-env": "7.26.9",
50
+ "@rollup/plugin-typescript": "12.1.2",
51
+ "@sgratzl/chartjs-chart-boxplot": "4.4.4",
52
+ "@types/jest": "29.5.14",
53
+ "canvas": "3.1.0",
54
+ "chartjs-adapter-luxon": "1.3.1",
55
+ "chartjs-chart-wordcloud": "4.4.4",
56
+ "chartjs-plugin-a11y-legend": "0.2.1",
53
57
  "cross-env": "7.0.3",
54
58
  "depcheck": "1.4.7",
55
59
  "jest": "29.7.0",
56
60
  "jest-environment-jsdom": "29.7.0",
57
- "rollup": "4.22.5",
61
+ "luxon": "3.6.1",
62
+ "rimraf": "6.0.1",
63
+ "rollup": "4.40.0",
58
64
  "rollup-plugin-copy": "3.5.0",
59
- "ts-jest": "29.2.5",
60
- "tslib": "2.7.0",
61
- "typescript": "5.6.2",
62
- "vite": "5.4.8"
65
+ "ts-jest": "29.3.2",
66
+ "tslib": "2.8.1",
67
+ "typescript": "5.8.3",
68
+ "vite": "6.2.6"
63
69
  },
64
70
  "dependencies": {
65
- "chart.js": "4.4.4",
66
- "chart2music": "1.17.0"
71
+ "chart.js": "4.4.8",
72
+ "chart2music": "1.18.1"
67
73
  }
68
74
  }