chartjs-chart-sankey 0.12.1 → 0.14.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Jukka Kurkela
3
+ Copyright (c) 2019-2024 Jukka Kurkela
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  [Chart.js](https://www.chartjs.org/) **^3.3** module for creating sankey diagrams
4
4
 
5
+ ![CI](https://github.com/kurkle/chartjs-chart-sankey/workflows/CI/badge.svg)
6
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=kurkle_chartjs-chart-sankey&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=kurkle_chartjs-chart-sankey)
7
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=kurkle_chartjs-chart-sankey&metric=coverage)](https://sonarcloud.io/summary/new_code?id=kurkle_chartjs-chart-sankey)
5
8
  [![npm](https://img.shields.io/npm/v/chartjs-chart-sankey.svg)](https://www.npmjs.com/package/chartjs-chart-sankey)
6
9
  [![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)
7
- ![Node.js CI](https://github.com/kurkle/chartjs-chart-sankey/workflows/Node.js%20CI/badge.svg)
8
10
  ![npm bundle size](https://img.shields.io/bundlephobia/min/chartjs-chart-sankey.svg)
9
11
  ![GitHub](https://img.shields.io/github/license/kurkle/chartjs-chart-sankey.svg)
10
12
 
@@ -56,6 +58,7 @@ const colors = {
56
58
  d: 'gray'
57
59
  };
58
60
 
61
+ const getHover = (key) => colors[key];
59
62
  const getColor = (key) => colors[key];
60
63
 
61
64
  const chart = new Chart(ctx, {
@@ -71,7 +74,11 @@ const chart = new Chart(ctx, {
71
74
  ],
72
75
  colorFrom: (c) => getColor(c.dataset.data[c.dataIndex].from),
73
76
  colorTo: (c) => getColor(c.dataset.data[c.dataIndex].to),
77
+ hoverColorFrom: (c) => getHover(c.dataset.data[c.dataIndex].from),
78
+ hoverColorTo: (c) => getHover(c.dataset.data[c.dataIndex].to),
74
79
  colorMode: 'gradient', // or 'from' or 'to'
80
+ /* optionally override default alpha (0.5) applied to colorFrom and colorTo */
81
+ alpha: 1,
75
82
  /* optional labels */
76
83
  labels: {
77
84
  a: 'Label A',
@@ -127,7 +134,7 @@ const chart = new Chart(ctx, {
127
134
 
128
135
  ## Example
129
136
 
130
- ![Sankey Example Image](sankey.png)
137
+ ![Sankey Example Image](test/fixtures/energy.png)
131
138
 
132
139
  ## Online examples
133
140