chartjs-plugin-chart2music 0.0.5 → 0.0.7

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
@@ -1,7 +1,7 @@
1
1
  # chartjs-plugin-chart2music
2
- chartjs plugin for chart2music.
2
+ [![npm version](https://badge.fury.io/js/chartjs-plugin-chart2music.svg)](https://badge.fury.io/js/chartjs-plugin-chart2music)
3
3
 
4
- **This is a beta release of this plugin**
4
+ **This is a beta release of this plugin. Not all chart.js features are supported yet.**
5
5
 
6
6
  Turns your chart.js charts into music so the blind can hear data. This plugin will automatically add Chart2Music, an interactive sonification library, to your chart.js charts. The contents of the chart element will be modified to best support screen reader users, and the interactions will be visually synchronized to provide support for keyboard-only users.
7
7
 
@@ -13,9 +13,9 @@ Add the chartjs2music plugin to your existing chart.js code like this:
13
13
 
14
14
  ```js
15
15
  import {Chart} from "chart.js/auto";
16
- import plugin from "chartjs-plugin-chart2music";
16
+ import chartjs2music from "chartjs-plugin-chart2music";
17
17
 
18
- Chart.register(plugin);
18
+ Chart.register(chartjs2music);
19
19
  ```
20
20
 
21
21
  That will register the plugin globally. Alternatively, if you only want to enable for a given chart, you can do this:
@@ -36,12 +36,52 @@ new Chart(canvasElement, {
36
36
 
37
37
  ```
38
38
 
39
+ ## Available options
40
+
41
+ The following plugin options are available:
42
+ * `errorCallback` - A callback that will return errors if any arise while the plugin works.
43
+ * `cc` - the equivalent of the [chart2music option `cc`](https://chart2music.com/docs/API/Config#axes)
44
+ * `audioEngine` - the equivalent of the [chart2music option `audioEngine`](https://chart2music.com/docs/API/Config#cc)
45
+ * `axes` - the equivalent of the [chart2music option `axes`](https://chart2music.com/docs/API/Config#axes)
46
+
47
+ Here's an example for providing options:
48
+ ```js
49
+ import {Chart} from "chart.js/auto";
50
+ import chartjs2music from "chartjs-plugin-chart2music";
51
+
52
+ new Chart(canvasElement, {
53
+ type: "bar",
54
+ data: {
55
+ datasets: [{
56
+ data: [1,4,2,8]
57
+ }]
58
+ },
59
+ options: {
60
+ plugins: {
61
+ chartjs2music: {
62
+ // All errors should be logged as errors
63
+ errorCallback: console.error,
64
+ // Here's a div I made to be the CC
65
+ cc: myDiv,
66
+ // The Y values should all be money
67
+ axes: {
68
+ y: {
69
+ format: (value) => "$" + value
70
+ }
71
+ }
72
+ }
73
+ }
74
+ },
75
+ plugins: [chartjs2music]
76
+ });
77
+ ```
78
+
39
79
  ## Supported features
40
80
 
41
81
  This plugin is currently in beta, so not all of the chart.js features are currently supported.
42
82
 
43
83
  A quick list of chart.js features we currently support includes:
44
- * Chart types: bar, line, pie, doughnut, polar, radar, and combinations therein.
84
+ * Chart types: bar, doughnut, line, pie, polar, radar, scatter, and combinations therein.
45
85
  * Boxplots using the `@sgratzl/chartjs-chart-boxplot` plugin (only support boxplots when there are no other chart types present)
46
86
  * Wordclouds using the `chartjs-chart-wordcloud` plugin
47
87
  * Axes options: `title`, `min`, `max`, `type="linear"`, `type="logarithmic"`.