chartjs-chart-sankey 0.7.1 → 0.9.0

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,6 +1,6 @@
1
1
  # chartjs-chart-sankey
2
2
 
3
- [Chart.js](https://www.chartjs.org/) **v3.3.x** module for creating sankey diagrams
3
+ [Chart.js](https://www.chartjs.org/) **^3.3** module for creating sankey diagrams
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/chartjs-chart-sankey.svg)](https://www.npmjs.com/package/chartjs-chart-sankey)
6
6
  [![pre-release](https://img.shields.io/github/v/release/kurkle/chartjs-chart-sankey?include_prereleases&style=flat-square)](https://github.com/kurkle/chartjs-chart-sankey/releases/latest)
@@ -29,7 +29,7 @@ You can use **chartjs-chart-sankey.js** as ES module. You'll need to manually re
29
29
 
30
30
  ```js
31
31
  import {Chart} from 'chart.js';
32
- import {SankeyController, Flow} from 'chartjs-chart-sankey/dist/chartjs-chart-sankey.esm';
32
+ import {SankeyController, Flow} from 'chartjs-chart-sankey';
33
33
 
34
34
  Chart.register(SankeyController, Flow);
35
35
  ```
@@ -49,6 +49,15 @@ const chart = new Chart(ctx, {
49
49
  Example:
50
50
 
51
51
  ```js
52
+ const colors = {
53
+ a: 'red',
54
+ b: 'green',
55
+ c: 'blue',
56
+ d: 'gray'
57
+ };
58
+
59
+ const getColor = (key) => colors[key];
60
+
52
61
  const chart = new Chart(ctx, {
53
62
  type: 'sankey',
54
63
  data: {
@@ -57,7 +66,8 @@ const chart = new Chart(ctx, {
57
66
  data: [
58
67
  {from: 'a', to: 'b', flow: 10},
59
68
  {from: 'a', to: 'c', flow: 5},
60
- {from: 'b', to: 'c', flow: 10}
69
+ {from: 'b', to: 'c', flow: 10},
70
+ {from: 'd', to: 'c', flow: 7}
61
71
  ],
62
72
  colorFrom: (c) => getColor(c.dataset.data[c.dataIndex].from),
63
73
  colorTo: (c) => getColor(c.dataset.data[c.dataIndex].to),
@@ -66,8 +76,19 @@ const chart = new Chart(ctx, {
66
76
  labels: {
67
77
  a: 'Label A',
68
78
  b: 'Label B',
69
- c: 'Label C'
70
- }
79
+ c: 'Label C',
80
+ d: 'Label D'
81
+ },
82
+ /* optional priority */
83
+ priority: {
84
+ b: 1,
85
+ d: 0
86
+ },
87
+ /* optional column overrides */
88
+ column: {
89
+ d: 1
90
+ },
91
+ size: 'max', // or 'min' if flow overlap is preferred
71
92
  }]
72
93
  },
73
94
  });