chartjs-plugin-autocolors 0.0.1 → 0.0.5
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 +1 -1
- package/README.md +53 -22
- package/dist/chartjs-plugin-autocolors.esm.js +58 -45
- package/dist/chartjs-plugin-autocolors.js +60 -47
- package/dist/chartjs-plugin-autocolors.min.js +4 -4
- package/package.json +14 -12
- package/.eslintrc.yml +0 -27
- package/.github/workflows/npmpublish.yml +0 -23
- package/.markdownlint.json +0 -3
- package/.vscode/tasks.json +0 -16
- package/dist/chartjs-plugin-autocolors.min.js.map +0 -1
- package/rollup.config.js +0 -61
- package/sample.png +0 -0
- package/samples/bar.html +0 -101
- package/samples/style.css +0 -13
- package/samples/utils.js +0 -36
- package/src/index.js +0 -55
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
*Automatic color generation for [Chart.js](https://www.chartjs.org)*
|
|
4
4
|
|
|
5
|
-
The generation
|
|
5
|
+
The generation is based on Janus Troelsen's answer at [Stack Overflow](https://stackoverflow.com/a/13781114/10359775).
|
|
6
6
|
|
|
7
7
|
This plugin requires Chart.js 3.0.0 or later. Could work with v2, but it is not supported.
|
|
8
8
|
|
|
9
9
|
**NOTE** the plugin does not automatically register.
|
|
10
10
|
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
11
15
|
## Installation
|
|
12
16
|
|
|
13
17
|
NPM:
|
|
@@ -46,14 +50,14 @@ All charts
|
|
|
46
50
|
Chart.register(autocolors);
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
Single chart
|
|
50
54
|
|
|
51
55
|
```js
|
|
52
56
|
const chart = new Chart(ctx, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
// ...
|
|
58
|
+
plugins: {
|
|
59
|
+
autocolors
|
|
60
|
+
}
|
|
57
61
|
});
|
|
58
62
|
```
|
|
59
63
|
|
|
@@ -63,14 +67,14 @@ If registered globally, it might be desirable to disable the autocolors for some
|
|
|
63
67
|
|
|
64
68
|
```js
|
|
65
69
|
const chart = new Chart(ctx, {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// ...
|
|
71
|
+
options: {
|
|
72
|
+
plugins: {
|
|
73
|
+
autocolors: {
|
|
74
|
+
enabled: false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
74
78
|
});
|
|
75
79
|
```
|
|
76
80
|
|
|
@@ -83,14 +87,41 @@ There are two modes, `'dataset'` (default) and `'data'`
|
|
|
83
87
|
|
|
84
88
|
```js
|
|
85
89
|
const chart = new Chart(ctx, {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
// ...
|
|
91
|
+
options: {
|
|
92
|
+
plugins: {
|
|
93
|
+
autocolors: {
|
|
94
|
+
mode: 'data'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Customize
|
|
102
|
+
|
|
103
|
+
A `customize` function can be provided to customize the generated colors.
|
|
104
|
+
The function is expected to return object containing `background` and `border` properties,
|
|
105
|
+
with values acceptable as colors by Chart.js.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const lighten = (color, value) => Chart.helpers.color(color).lighten(value).rgbString();
|
|
109
|
+
|
|
110
|
+
const chart = new Chart(ctx, {
|
|
111
|
+
// ...
|
|
112
|
+
options: {
|
|
113
|
+
plugins: {
|
|
114
|
+
autocolors: {
|
|
115
|
+
customize(context) {
|
|
116
|
+
const colors = context.colors;
|
|
117
|
+
return {
|
|
118
|
+
background: lighten(colors.background, 0.5),
|
|
119
|
+
border: lighten(colors.border, 0.5)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
94
125
|
});
|
|
95
126
|
```
|
|
96
127
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* chartjs-plugin-autocolors v0.0.
|
|
2
|
+
* chartjs-plugin-autocolors v0.0.5
|
|
3
3
|
* https://github.com/kurkle/chartjs-plugin-autocolors#readme
|
|
4
|
-
* (c)
|
|
4
|
+
* (c) 2021 Jukka Kurkela
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
7
|
/*!
|
|
@@ -44,57 +44,70 @@ function hsv2rgb(h, s, v) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function* hueGen() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
yield 0;
|
|
48
|
+
for (let i = 1; i < 10; i++) {
|
|
49
|
+
const d = 1 << i;
|
|
50
|
+
for (let j = 1; j <= d; j += 2) {
|
|
51
|
+
yield j / d;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function* colorGen() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const hue = hueGen();
|
|
58
|
+
let h = hue.next();
|
|
59
|
+
while (!h.done) {
|
|
60
|
+
let rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.8);
|
|
61
|
+
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
62
|
+
rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.5);
|
|
63
|
+
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
64
|
+
h = hue.next();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function setColors(dataset, background, border) {
|
|
69
|
+
dataset.backgroundColor = dataset.backgroundColor || background;
|
|
70
|
+
dataset.borderColor = dataset.borderColor || border;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getNext(color, customize, context) {
|
|
74
|
+
const c = color.next().value;
|
|
75
|
+
if (typeof customize === 'function') {
|
|
76
|
+
return customize(Object.assign({colors: c}, context));
|
|
77
|
+
}
|
|
78
|
+
return c;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
var index = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
id: 'autocolors',
|
|
83
|
+
beforeUpdate(chart, args, options) {
|
|
84
|
+
const {mode = 'dataset', enabled = true, customize} = options;
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
if (!enabled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
const color = colorGen();
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
for (const dataset of chart.data.datasets) {
|
|
93
|
+
if (dataset.backgroundColor && dataset.borderColor) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (mode === 'dataset') {
|
|
97
|
+
const c = getNext(color, customize, {chart, datasetIndex: dataset.index});
|
|
98
|
+
setColors(dataset, c.background, c.border);
|
|
99
|
+
} else {
|
|
100
|
+
const background = [];
|
|
101
|
+
const border = [];
|
|
102
|
+
for (let i = 0; i < dataset.data.length; i++) {
|
|
103
|
+
const c = getNext(color, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
|
|
104
|
+
background.push(c.background);
|
|
105
|
+
border.push(c.border);
|
|
106
|
+
}
|
|
107
|
+
setColors(dataset, background, border);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
98
111
|
};
|
|
99
112
|
|
|
100
|
-
export default
|
|
113
|
+
export { index as default };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* chartjs-plugin-autocolors v0.0.
|
|
2
|
+
* chartjs-plugin-autocolors v0.0.5
|
|
3
3
|
* https://github.com/kurkle/chartjs-plugin-autocolors#readme
|
|
4
|
-
* (c)
|
|
4
|
+
* (c) 2021 Jukka Kurkela
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
8
8
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
9
9
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
10
|
-
(global = global || self, global[
|
|
11
|
-
}(this, (function () { 'use strict';
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["chartjs-plugin-autocolors"] = factory());
|
|
11
|
+
})(this, (function () { 'use strict';
|
|
12
12
|
|
|
13
13
|
/*!
|
|
14
14
|
* @kurkle/color v0.1.9
|
|
@@ -50,59 +50,72 @@ function hsv2rgb(h, s, v) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function* hueGen() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
yield 0;
|
|
54
|
+
for (let i = 1; i < 10; i++) {
|
|
55
|
+
const d = 1 << i;
|
|
56
|
+
for (let j = 1; j <= d; j += 2) {
|
|
57
|
+
yield j / d;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function* colorGen() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const hue = hueGen();
|
|
64
|
+
let h = hue.next();
|
|
65
|
+
while (!h.done) {
|
|
66
|
+
let rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.8);
|
|
67
|
+
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
68
|
+
rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.5);
|
|
69
|
+
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
70
|
+
h = hue.next();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function setColors(dataset, background, border) {
|
|
75
|
+
dataset.backgroundColor = dataset.backgroundColor || background;
|
|
76
|
+
dataset.borderColor = dataset.borderColor || border;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getNext(color, customize, context) {
|
|
80
|
+
const c = color.next().value;
|
|
81
|
+
if (typeof customize === 'function') {
|
|
82
|
+
return customize(Object.assign({colors: c}, context));
|
|
83
|
+
}
|
|
84
|
+
return c;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
87
|
var index = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
id: 'autocolors',
|
|
89
|
+
beforeUpdate(chart, args, options) {
|
|
90
|
+
const {mode = 'dataset', enabled = true, customize} = options;
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
if (!enabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
82
95
|
|
|
83
|
-
|
|
96
|
+
const color = colorGen();
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
for (const dataset of chart.data.datasets) {
|
|
99
|
+
if (dataset.backgroundColor && dataset.borderColor) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (mode === 'dataset') {
|
|
103
|
+
const c = getNext(color, customize, {chart, datasetIndex: dataset.index});
|
|
104
|
+
setColors(dataset, c.background, c.border);
|
|
105
|
+
} else {
|
|
106
|
+
const background = [];
|
|
107
|
+
const border = [];
|
|
108
|
+
for (let i = 0; i < dataset.data.length; i++) {
|
|
109
|
+
const c = getNext(color, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
|
|
110
|
+
background.push(c.background);
|
|
111
|
+
border.push(c.border);
|
|
112
|
+
}
|
|
113
|
+
setColors(dataset, background, border);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
104
117
|
};
|
|
105
118
|
|
|
106
119
|
return index;
|
|
107
120
|
|
|
108
|
-
}))
|
|
121
|
+
}));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* chartjs-plugin-autocolors v0.0.
|
|
2
|
+
* chartjs-plugin-autocolors v0.0.5
|
|
3
3
|
* https://github.com/kurkle/chartjs-plugin-autocolors#readme
|
|
4
|
-
* (c)
|
|
4
|
+
* (c) 2021 Jukka Kurkela
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
|
-
!function(
|
|
7
|
+
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(o="undefined"!=typeof globalThis?globalThis:o||self)["chartjs-plugin-autocolors"]=t()}(this,(function(){"use strict";
|
|
8
8
|
/*!
|
|
9
9
|
* @kurkle/color v0.1.9
|
|
10
10
|
* https://github.com/kurkle/color#readme
|
|
11
11
|
* (c) 2020 Jukka Kurkela
|
|
12
12
|
* Released under the MIT License
|
|
13
|
-
*/function
|
|
13
|
+
*/function o(o){return o+.5|0}const t=(o,t,n)=>Math.max(Math.min(o,n),t);function n(n){return t(o(255*n),0,255)}function e(n){return n&&(n.a<255?`rgba(${n.r}, ${n.g}, ${n.b}, ${function(n){return t(o(n/2.55)/100,0,1)}(n.a)})`:`rgb(${n.r}, ${n.g}, ${n.b})`)}function r(o,t,n){const e=(e,r=(e+o/60)%6)=>n-n*t*Math.max(Math.min(r,4-r,1),0);return[e(5),e(3),e(1)]}function a(o,t,e){return a=r,d=o,u=t,c=e,(Array.isArray(d)?a(d[0],d[1],d[2]):a(d,u,c)).map(n);var a,d,u,c}function d(o,t,n){o.backgroundColor=o.backgroundColor||t,o.borderColor=o.borderColor||n}function u(o,t,n){const e=o.next().value;return"function"==typeof t?t(Object.assign({colors:e},n)):e}return{id:"autocolors",beforeUpdate(o,t,n){const{mode:r="dataset",enabled:c=!0,customize:i}=n;if(!c)return;const s=function*(){const o=function*(){yield 0;for(let o=1;o<10;o++){const t=1<<o;for(let o=1;o<=t;o+=2)yield o/t}}();let t=o.next();for(;!t.done;){let n=a(Math.round(360*t.value),.6,.8);yield{background:e({r:n[0],g:n[1],b:n[2],a:192}),border:e({r:n[0],g:n[1],b:n[2],a:144})},n=a(Math.round(360*t.value),.6,.5),yield{background:e({r:n[0],g:n[1],b:n[2],a:192}),border:e({r:n[0],g:n[1],b:n[2],a:144})},t=o.next()}}();for(const t of o.data.datasets)if(!t.backgroundColor||!t.borderColor)if("dataset"===r){const n=u(s,i,{chart:o,datasetIndex:t.index});d(t,n.background,n.border)}else{const n=[],e=[];for(let r=0;r<t.data.length;r++){const a=u(s,i,{chart:o,datasetIndex:t.index,dataIndex:r});n.push(a.background),e.push(a.border)}d(t,n,e)}}}}));
|
|
14
14
|
//# sourceMappingURL=chartjs-plugin-autocolors.min.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chartjs-plugin-autocolors",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Automatic color generation for Chart.js",
|
|
5
5
|
"main": "dist/chartjs-plugin-autocolors.js",
|
|
6
|
-
"module": "dist/chartjs-plugin-autocolors.
|
|
6
|
+
"module": "dist/chartjs-plugin-autocolors.esm.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rollup -c",
|
|
9
9
|
"lint": "eslint samples/**/*.html samples/**/*.js src/**/*.js **/*.md"
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/kurkle/chartjs-plugin-autocolors.git"
|
|
14
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/*.js"
|
|
17
|
+
],
|
|
15
18
|
"keywords": [
|
|
16
19
|
"chart.js",
|
|
17
20
|
"plugin",
|
|
@@ -28,14 +31,13 @@
|
|
|
28
31
|
"homepage": "https://github.com/kurkle/chartjs-plugin-autocolors#readme",
|
|
29
32
|
"devDependencies": {
|
|
30
33
|
"@kurkle/color": "^0.1.9",
|
|
31
|
-
"@rollup/plugin-node-resolve": "^
|
|
32
|
-
"eslint": "^
|
|
33
|
-
"eslint-config-chartjs": "^0.
|
|
34
|
-
"eslint-
|
|
35
|
-
"eslint-plugin-html": "^6.
|
|
36
|
-
"eslint-plugin-markdown": "^
|
|
37
|
-
"rollup": "^2.
|
|
38
|
-
"rollup-plugin-terser": "^
|
|
39
|
-
}
|
|
40
|
-
"dependencies": {}
|
|
34
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
35
|
+
"eslint": "^8.5.0",
|
|
36
|
+
"eslint-config-chartjs": "^0.3.0",
|
|
37
|
+
"eslint-plugin-es": "^4.1.0",
|
|
38
|
+
"eslint-plugin-html": "^6.1.2",
|
|
39
|
+
"eslint-plugin-markdown": "^2.2.0",
|
|
40
|
+
"rollup": "^2.33.2",
|
|
41
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
42
|
+
}
|
|
41
43
|
}
|
package/.eslintrc.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
extends:
|
|
2
|
-
- chartjs
|
|
3
|
-
- esnext
|
|
4
|
-
|
|
5
|
-
env:
|
|
6
|
-
es6: true
|
|
7
|
-
browser: true
|
|
8
|
-
node: true
|
|
9
|
-
|
|
10
|
-
parser: babel-eslint
|
|
11
|
-
|
|
12
|
-
parserOptions:
|
|
13
|
-
ecmaVersion: 7
|
|
14
|
-
sourceType: module
|
|
15
|
-
ecmaFeatures:
|
|
16
|
-
modules: true
|
|
17
|
-
|
|
18
|
-
plugins: ['html', 'markdown']
|
|
19
|
-
|
|
20
|
-
overrides: [{
|
|
21
|
-
files: ["**/*.md"],
|
|
22
|
-
rules: {
|
|
23
|
-
no-undef: "off",
|
|
24
|
-
no-unused-vars: "off",
|
|
25
|
-
import/no-unresolved: "off"
|
|
26
|
-
}
|
|
27
|
-
}]
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Node.js Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created, edited]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
publish-npm:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- uses: actions/setup-node@v1
|
|
13
|
-
with:
|
|
14
|
-
node-version: 12
|
|
15
|
-
registry-url: https://registry.npmjs.org/
|
|
16
|
-
- name: Build
|
|
17
|
-
run: |
|
|
18
|
-
npm ci
|
|
19
|
-
npm run lint
|
|
20
|
-
npm run build
|
|
21
|
-
- run: npm publish --access public
|
|
22
|
-
env:
|
|
23
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/.markdownlint.json
DELETED
package/.vscode/tasks.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chartjs-plugin-autocolors.min.js","sources":["../node_modules/@kurkle/color/dist/color.esm.js","../src/index.js"],"sourcesContent":["/*!\n * @kurkle/color v0.1.9\n * https://github.com/kurkle/color#readme\n * (c) 2020 Jukka Kurkela\n * Released under the MIT License\n */\nconst map = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, A: 10, B: 11, C: 12, D: 13, E: 14, F: 15, a: 10, b: 11, c: 12, d: 13, e: 14, f: 15};\nconst hex = '0123456789ABCDEF';\nconst h1 = (b) => hex[b & 0xF];\nconst h2 = (b) => hex[(b & 0xF0) >> 4] + hex[b & 0xF];\nconst eq = (b) => (((b & 0xF0) >> 4) === (b & 0xF));\nfunction isShort(v) {\n\treturn eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a);\n}\nfunction hexParse(str) {\n\tvar len = str.length;\n\tvar ret;\n\tif (str[0] === '#') {\n\t\tif (len === 4 || len === 5) {\n\t\t\tret = {\n\t\t\t\tr: 255 & map[str[1]] * 17,\n\t\t\t\tg: 255 & map[str[2]] * 17,\n\t\t\t\tb: 255 & map[str[3]] * 17,\n\t\t\t\ta: len === 5 ? map[str[4]] * 17 : 255\n\t\t\t};\n\t\t} else if (len === 7 || len === 9) {\n\t\t\tret = {\n\t\t\t\tr: map[str[1]] << 4 | map[str[2]],\n\t\t\t\tg: map[str[3]] << 4 | map[str[4]],\n\t\t\t\tb: map[str[5]] << 4 | map[str[6]],\n\t\t\t\ta: len === 9 ? (map[str[7]] << 4 | map[str[8]]) : 255\n\t\t\t};\n\t\t}\n\t}\n\treturn ret;\n}\nfunction hexString(v) {\n\tvar f = isShort(v) ? h1 : h2;\n\treturn v\n\t\t? '#' + f(v.r) + f(v.g) + f(v.b) + (v.a < 255 ? f(v.a) : '')\n\t\t: v;\n}\n\nfunction round(v) {\n\treturn v + 0.5 | 0;\n}\nconst lim = (v, l, h) => Math.max(Math.min(v, h), l);\nfunction p2b(v) {\n\treturn lim(round(v * 2.55), 0, 255);\n}\nfunction b2p(v) {\n\treturn lim(round(v / 2.55), 0, 100);\n}\nfunction n2b(v) {\n\treturn lim(round(v * 255), 0, 255);\n}\nfunction b2n(v) {\n\treturn lim(round(v / 2.55) / 100, 0, 1);\n}\nfunction n2p(v) {\n\treturn lim(round(v * 100), 0, 100);\n}\n\nconst RGB_RE = /^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\nfunction rgbParse(str) {\n\tconst m = RGB_RE.exec(str);\n\tlet a = 255;\n\tlet r, g, b;\n\tif (!m) {\n\t\treturn;\n\t}\n\tif (m[7] !== r) {\n\t\tconst v = +m[7];\n\t\ta = 255 & (m[8] ? p2b(v) : v * 255);\n\t}\n\tr = +m[1];\n\tg = +m[3];\n\tb = +m[5];\n\tr = 255 & (m[2] ? p2b(r) : r);\n\tg = 255 & (m[4] ? p2b(g) : g);\n\tb = 255 & (m[6] ? p2b(b) : b);\n\treturn {\n\t\tr: r,\n\t\tg: g,\n\t\tb: b,\n\t\ta: a\n\t};\n}\nfunction rgbString(v) {\n\treturn v && (\n\t\tv.a < 255\n\t\t\t? `rgba(${v.r}, ${v.g}, ${v.b}, ${b2n(v.a)})`\n\t\t\t: `rgb(${v.r}, ${v.g}, ${v.b})`\n\t);\n}\n\nconst HUE_RE = /^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\nfunction hsl2rgbn(h, s, l) {\n\tconst a = s * Math.min(l, 1 - l);\n\tconst f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n\treturn [f(0), f(8), f(4)];\n}\nfunction hsv2rgbn(h, s, v) {\n\tconst f = (n, k = (n + h / 60) % 6) => v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);\n\treturn [f(5), f(3), f(1)];\n}\nfunction hwb2rgbn(h, w, b) {\n\tconst rgb = hsl2rgbn(h, 1, 0.5);\n\tlet i;\n\tif (w + b > 1) {\n\t\ti = 1 / (w + b);\n\t\tw *= i;\n\t\tb *= i;\n\t}\n\tfor (i = 0; i < 3; i++) {\n\t\trgb[i] *= 1 - w - b;\n\t\trgb[i] += w;\n\t}\n\treturn rgb;\n}\nfunction rgb2hsl(v) {\n\tconst range = 255;\n\tconst r = v.r / range;\n\tconst g = v.g / range;\n\tconst b = v.b / range;\n\tconst max = Math.max(r, g, b);\n\tconst min = Math.min(r, g, b);\n\tconst l = (max + min) / 2;\n\tlet h, s, d;\n\tif (max !== min) {\n\t\td = max - min;\n\t\ts = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\t\th = max === r\n\t\t\t? ((g - b) / d) + (g < b ? 6 : 0)\n\t\t\t: max === g\n\t\t\t\t? (b - r) / d + 2\n\t\t\t\t: (r - g) / d + 4;\n\t\th = h * 60 + 0.5;\n\t}\n\treturn [h | 0, s || 0, l];\n}\nfunction calln(f, a, b, c) {\n\treturn (\n\t\tArray.isArray(a)\n\t\t\t? f(a[0], a[1], a[2])\n\t\t\t: f(a, b, c)\n\t).map(n2b);\n}\nfunction hsl2rgb(h, s, l) {\n\treturn calln(hsl2rgbn, h, s, l);\n}\nfunction hwb2rgb(h, w, b) {\n\treturn calln(hwb2rgbn, h, w, b);\n}\nfunction hsv2rgb(h, s, v) {\n\treturn calln(hsv2rgbn, h, s, v);\n}\nfunction hue(h) {\n\treturn (h % 360 + 360) % 360;\n}\nfunction hueParse(str) {\n\tconst m = HUE_RE.exec(str);\n\tlet a = 255;\n\tlet v;\n\tif (!m) {\n\t\treturn;\n\t}\n\tif (m[5] !== v) {\n\t\ta = m[6] ? p2b(+m[5]) : n2b(+m[5]);\n\t}\n\tconst h = hue(+m[2]);\n\tconst p1 = +m[3] / 100;\n\tconst p2 = +m[4] / 100;\n\tif (m[1] === 'hwb') {\n\t\tv = hwb2rgb(h, p1, p2);\n\t} else if (m[1] === 'hsv') {\n\t\tv = hsv2rgb(h, p1, p2);\n\t} else {\n\t\tv = hsl2rgb(h, p1, p2);\n\t}\n\treturn {\n\t\tr: v[0],\n\t\tg: v[1],\n\t\tb: v[2],\n\t\ta: a\n\t};\n}\nfunction rotate(v, deg) {\n\tvar h = rgb2hsl(v);\n\th[0] = hue(h[0] + deg);\n\th = hsl2rgb(h);\n\tv.r = h[0];\n\tv.g = h[1];\n\tv.b = h[2];\n}\nfunction hslString(v) {\n\tif (!v) {\n\t\treturn;\n\t}\n\tconst a = rgb2hsl(v);\n\tconst h = a[0];\n\tconst s = n2p(a[1]);\n\tconst l = n2p(a[2]);\n\treturn v.a < 255\n\t\t? `hsla(${h}, ${s}%, ${l}%, ${b2n(v.a)})`\n\t\t: `hsl(${h}, ${s}%, ${l}%)`;\n}\n\nconst map$1 = {\n\tx: 'dark',\n\tZ: 'light',\n\tY: 're',\n\tX: 'blu',\n\tW: 'gr',\n\tV: 'medium',\n\tU: 'slate',\n\tA: 'ee',\n\tT: 'ol',\n\tS: 'or',\n\tB: 'ra',\n\tC: 'lateg',\n\tD: 'ights',\n\tR: 'in',\n\tQ: 'turquois',\n\tE: 'hi',\n\tP: 'ro',\n\tO: 'al',\n\tN: 'le',\n\tM: 'de',\n\tL: 'yello',\n\tF: 'en',\n\tK: 'ch',\n\tG: 'arks',\n\tH: 'ea',\n\tI: 'ightg',\n\tJ: 'wh'\n};\nconst names = {\n\tOiceXe: 'f0f8ff',\n\tantiquewEte: 'faebd7',\n\taqua: 'ffff',\n\taquamarRe: '7fffd4',\n\tazuY: 'f0ffff',\n\tbeige: 'f5f5dc',\n\tbisque: 'ffe4c4',\n\tblack: '0',\n\tblanKedOmond: 'ffebcd',\n\tXe: 'ff',\n\tXeviTet: '8a2be2',\n\tbPwn: 'a52a2a',\n\tburlywood: 'deb887',\n\tcaMtXe: '5f9ea0',\n\tKartYuse: '7fff00',\n\tKocTate: 'd2691e',\n\tcSO: 'ff7f50',\n\tcSnflowerXe: '6495ed',\n\tcSnsilk: 'fff8dc',\n\tcrimson: 'dc143c',\n\tcyan: 'ffff',\n\txXe: '8b',\n\txcyan: '8b8b',\n\txgTMnPd: 'b8860b',\n\txWay: 'a9a9a9',\n\txgYF: '6400',\n\txgYy: 'a9a9a9',\n\txkhaki: 'bdb76b',\n\txmagFta: '8b008b',\n\txTivegYF: '556b2f',\n\txSange: 'ff8c00',\n\txScEd: '9932cc',\n\txYd: '8b0000',\n\txsOmon: 'e9967a',\n\txsHgYF: '8fbc8f',\n\txUXe: '483d8b',\n\txUWay: '2f4f4f',\n\txUgYy: '2f4f4f',\n\txQe: 'ced1',\n\txviTet: '9400d3',\n\tdAppRk: 'ff1493',\n\tdApskyXe: 'bfff',\n\tdimWay: '696969',\n\tdimgYy: '696969',\n\tdodgerXe: '1e90ff',\n\tfiYbrick: 'b22222',\n\tflSOwEte: 'fffaf0',\n\tfoYstWAn: '228b22',\n\tfuKsia: 'ff00ff',\n\tgaRsbSo: 'dcdcdc',\n\tghostwEte: 'f8f8ff',\n\tgTd: 'ffd700',\n\tgTMnPd: 'daa520',\n\tWay: '808080',\n\tgYF: '8000',\n\tgYFLw: 'adff2f',\n\tgYy: '808080',\n\thoneyMw: 'f0fff0',\n\thotpRk: 'ff69b4',\n\tRdianYd: 'cd5c5c',\n\tRdigo: '4b0082',\n\tivSy: 'fffff0',\n\tkhaki: 'f0e68c',\n\tlavFMr: 'e6e6fa',\n\tlavFMrXsh: 'fff0f5',\n\tlawngYF: '7cfc00',\n\tNmoncEffon: 'fffacd',\n\tZXe: 'add8e6',\n\tZcSO: 'f08080',\n\tZcyan: 'e0ffff',\n\tZgTMnPdLw: 'fafad2',\n\tZWay: 'd3d3d3',\n\tZgYF: '90ee90',\n\tZgYy: 'd3d3d3',\n\tZpRk: 'ffb6c1',\n\tZsOmon: 'ffa07a',\n\tZsHgYF: '20b2aa',\n\tZskyXe: '87cefa',\n\tZUWay: '778899',\n\tZUgYy: '778899',\n\tZstAlXe: 'b0c4de',\n\tZLw: 'ffffe0',\n\tlime: 'ff00',\n\tlimegYF: '32cd32',\n\tlRF: 'faf0e6',\n\tmagFta: 'ff00ff',\n\tmaPon: '800000',\n\tVaquamarRe: '66cdaa',\n\tVXe: 'cd',\n\tVScEd: 'ba55d3',\n\tVpurpN: '9370db',\n\tVsHgYF: '3cb371',\n\tVUXe: '7b68ee',\n\tVsprRggYF: 'fa9a',\n\tVQe: '48d1cc',\n\tVviTetYd: 'c71585',\n\tmidnightXe: '191970',\n\tmRtcYam: 'f5fffa',\n\tmistyPse: 'ffe4e1',\n\tmoccasR: 'ffe4b5',\n\tnavajowEte: 'ffdead',\n\tnavy: '80',\n\tTdlace: 'fdf5e6',\n\tTive: '808000',\n\tTivedBb: '6b8e23',\n\tSange: 'ffa500',\n\tSangeYd: 'ff4500',\n\tScEd: 'da70d6',\n\tpOegTMnPd: 'eee8aa',\n\tpOegYF: '98fb98',\n\tpOeQe: 'afeeee',\n\tpOeviTetYd: 'db7093',\n\tpapayawEp: 'ffefd5',\n\tpHKpuff: 'ffdab9',\n\tperu: 'cd853f',\n\tpRk: 'ffc0cb',\n\tplum: 'dda0dd',\n\tpowMrXe: 'b0e0e6',\n\tpurpN: '800080',\n\tYbeccapurpN: '663399',\n\tYd: 'ff0000',\n\tPsybrown: 'bc8f8f',\n\tPyOXe: '4169e1',\n\tsaddNbPwn: '8b4513',\n\tsOmon: 'fa8072',\n\tsandybPwn: 'f4a460',\n\tsHgYF: '2e8b57',\n\tsHshell: 'fff5ee',\n\tsiFna: 'a0522d',\n\tsilver: 'c0c0c0',\n\tskyXe: '87ceeb',\n\tUXe: '6a5acd',\n\tUWay: '708090',\n\tUgYy: '708090',\n\tsnow: 'fffafa',\n\tsprRggYF: 'ff7f',\n\tstAlXe: '4682b4',\n\ttan: 'd2b48c',\n\tteO: '8080',\n\ttEstN: 'd8bfd8',\n\ttomato: 'ff6347',\n\tQe: '40e0d0',\n\tviTet: 'ee82ee',\n\tJHt: 'f5deb3',\n\twEte: 'ffffff',\n\twEtesmoke: 'f5f5f5',\n\tLw: 'ffff00',\n\tLwgYF: '9acd32'\n};\nfunction unpack() {\n\tconst unpacked = {};\n\tconst keys = Object.keys(names);\n\tconst tkeys = Object.keys(map$1);\n\tlet i, j, k, ok, nk;\n\tfor (i = 0; i < keys.length; i++) {\n\t\tok = nk = keys[i];\n\t\tfor (j = 0; j < tkeys.length; j++) {\n\t\t\tk = tkeys[j];\n\t\t\tnk = nk.replace(k, map$1[k]);\n\t\t}\n\t\tk = parseInt(names[ok], 16);\n\t\tunpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF];\n\t}\n\treturn unpacked;\n}\n\nlet names$1;\nfunction nameParse(str) {\n\tif (!names$1) {\n\t\tnames$1 = unpack();\n\t\tnames$1.transparent = [0, 0, 0, 0];\n\t}\n\tconst a = names$1[str.toLowerCase()];\n\treturn a && {\n\t\tr: a[0],\n\t\tg: a[1],\n\t\tb: a[2],\n\t\ta: a.length === 4 ? a[3] : 255\n\t};\n}\n\nfunction modHSL(v, i, ratio) {\n\tif (v) {\n\t\tlet tmp = rgb2hsl(v);\n\t\ttmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1));\n\t\ttmp = hsl2rgb(tmp);\n\t\tv.r = tmp[0];\n\t\tv.g = tmp[1];\n\t\tv.b = tmp[2];\n\t}\n}\nfunction clone(v, proto) {\n\treturn v ? Object.assign(proto || {}, v) : v;\n}\nfunction fromObject(input) {\n\tvar v = {r: 0, g: 0, b: 0, a: 255};\n\tif (Array.isArray(input)) {\n\t\tif (input.length >= 3) {\n\t\t\tv = {r: input[0], g: input[1], b: input[2], a: 255};\n\t\t\tif (input.length > 3) {\n\t\t\t\tv.a = n2b(input[3]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tv = clone(input, {r: 0, g: 0, b: 0, a: 1});\n\t\tv.a = n2b(v.a);\n\t}\n\treturn v;\n}\nfunction functionParse(str) {\n\tif (str.charAt(0) === 'r') {\n\t\treturn rgbParse(str);\n\t}\n\treturn hueParse(str);\n}\nclass Color {\n\tconstructor(input) {\n\t\tif (input instanceof Color) {\n\t\t\treturn input;\n\t\t}\n\t\tconst type = typeof input;\n\t\tlet v;\n\t\tif (type === 'object') {\n\t\t\tv = fromObject(input);\n\t\t} else if (type === 'string') {\n\t\t\tv = hexParse(input) || nameParse(input) || functionParse(input);\n\t\t}\n\t\tthis._rgb = v;\n\t\tthis._valid = !!v;\n\t}\n\tget valid() {\n\t\treturn this._valid;\n\t}\n\tget rgb() {\n\t\tvar v = clone(this._rgb);\n\t\tif (v) {\n\t\t\tv.a = b2n(v.a);\n\t\t}\n\t\treturn v;\n\t}\n\tset rgb(obj) {\n\t\tthis._rgb = fromObject(obj);\n\t}\n\trgbString() {\n\t\treturn this._valid ? rgbString(this._rgb) : this._rgb;\n\t}\n\thexString() {\n\t\treturn this._valid ? hexString(this._rgb) : this._rgb;\n\t}\n\thslString() {\n\t\treturn this._valid ? hslString(this._rgb) : this._rgb;\n\t}\n\tmix(color, weight) {\n\t\tconst me = this;\n\t\tif (color) {\n\t\t\tconst c1 = me.rgb;\n\t\t\tconst c2 = color.rgb;\n\t\t\tlet w2;\n\t\t\tconst p = weight === w2 ? 0.5 : weight;\n\t\t\tconst w = 2 * p - 1;\n\t\t\tconst a = c1.a - c2.a;\n\t\t\tconst w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n\t\t\tw2 = 1 - w1;\n\t\t\tc1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5;\n\t\t\tc1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5;\n\t\t\tc1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5;\n\t\t\tc1.a = p * c1.a + (1 - p) * c2.a;\n\t\t\tme.rgb = c1;\n\t\t}\n\t\treturn me;\n\t}\n\tclone() {\n\t\treturn new Color(this.rgb);\n\t}\n\talpha(a) {\n\t\tthis._rgb.a = n2b(a);\n\t\treturn this;\n\t}\n\tclearer(ratio) {\n\t\tconst rgb = this._rgb;\n\t\trgb.a *= 1 - ratio;\n\t\treturn this;\n\t}\n\tgreyscale() {\n\t\tconst rgb = this._rgb;\n\t\tconst val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11);\n\t\trgb.r = rgb.g = rgb.b = val;\n\t\treturn this;\n\t}\n\topaquer(ratio) {\n\t\tconst rgb = this._rgb;\n\t\trgb.a *= 1 + ratio;\n\t\treturn this;\n\t}\n\tnegate() {\n\t\tconst v = this._rgb;\n\t\tv.r = 255 - v.r;\n\t\tv.g = 255 - v.g;\n\t\tv.b = 255 - v.b;\n\t\treturn this;\n\t}\n\tlighten(ratio) {\n\t\tmodHSL(this._rgb, 2, ratio);\n\t\treturn this;\n\t}\n\tdarken(ratio) {\n\t\tmodHSL(this._rgb, 2, -ratio);\n\t\treturn this;\n\t}\n\tsaturate(ratio) {\n\t\tmodHSL(this._rgb, 1, ratio);\n\t\treturn this;\n\t}\n\tdesaturate(ratio) {\n\t\tmodHSL(this._rgb, 1, -ratio);\n\t\treturn this;\n\t}\n\trotate(deg) {\n\t\trotate(this._rgb, deg);\n\t\treturn this;\n\t}\n}\n\nfunction index_esm(input) {\n\treturn new Color(input);\n}\n\nexport default index_esm;\nexport { Color, b2n, b2p, hexParse, hexString, hsl2rgb, hslString, hsv2rgb, hueParse, hwb2rgb, n2b, n2p, nameParse, p2b, rgb2hsl, rgbParse, rgbString, rotate, round };\n","import {hsv2rgb, rgbString} from '@kurkle/color';\n\nfunction* hueGen() {\n\tyield 0;\n\tfor (let i = 1; i < 10; i++) {\n\t\tconst d = 1 << i;\n\t\tfor (let j = 1; j <= d; j += 2) {\n\t\t\tyield j / d;\n\t\t}\n\t}\n}\n\nfunction* colorGen() {\n\tconst hue = hueGen();\n\tlet h = hue.next();\n\twhile (!h.done) {\n\t\tlet rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.8);\n\t\tyield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};\n\t\trgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.5);\n\t\tyield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};\n\t\th = hue.next();\n\t}\n}\n\nexport default {\n\tid: 'autocolors',\n\tbeforeUpdate(chart, options) {\n\t\tconst {mode = 'dataset', enabled = true} = options;\n\n\t\tif (!enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst color = colorGen();\n\n\t\tchart.data.datasets.forEach(dataset => {\n\t\t\tif (mode === 'dataset') {\n\t\t\t\tconst c = color.next().value;\n\t\t\t\tdataset.backgroundColor = c.background;\n\t\t\t\tdataset.borderColor = c.border;\n\t\t\t} else {\n\t\t\t\tconst background = [];\n\t\t\t\tconst border = [];\n\t\t\t\t// eslint-disable-next-line array-callback-return\n\t\t\t\tdataset.data.map(() => {\n\t\t\t\t\tconst c = color.next().value;\n\t\t\t\t\tbackground.push(c.background);\n\t\t\t\t\tborder.push(c.border);\n\t\t\t\t});\n\t\t\t\tdataset.backgroundColor = background;\n\t\t\t\tdataset.borderColor = border;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["round","v","lim","l","h","Math","max","min","n2b","rgbString","a","r","g","b","b2n","hsv2rgbn","s","f","n","k","hsv2rgb","c","Array","isArray","map","id","[object Object]","chart","options","mode","enabled","color","hue","i","d","j","hueGen","next","done","rgb","value","background","border","colorGen","data","datasets","forEach","dataset","backgroundColor","borderColor","push"],"mappings":";;;;;;;;;;;;GA2CA,SAASA,EAAMC,GACd,OAAOA,EAAI,GAAM,EAElB,MAAMC,EAAM,CAACD,EAAGE,EAAGC,IAAMC,KAAKC,IAAID,KAAKE,IAAIN,EAAGG,GAAID,GAOlD,SAASK,EAAIP,GACZ,OAAOC,EAAIF,EAAU,IAAJC,GAAU,EAAG,KAkC/B,SAASQ,EAAUR,GAClB,OAAOA,IACNA,EAAES,EAAI,IACH,QAAQT,EAAEU,MAAMV,EAAEW,MAAMX,EAAEY,MAnC/B,SAAaZ,GACZ,OAAOC,EAAIF,EAAMC,EAAI,MAAQ,IAAK,EAAG,GAkCDa,CAAIb,EAAES,MACtC,OAAOT,EAAEU,MAAMV,EAAEW,MAAMX,EAAEY,MAU9B,SAASE,EAASX,EAAGY,EAAGf,GACvB,MAAMgB,EAAI,CAACC,EAAGC,GAAKD,EAAId,EAAI,IAAM,IAAMH,EAAIA,EAAIe,EAAIX,KAAKC,IAAID,KAAKE,IAAIY,EAAG,EAAIA,EAAG,GAAI,GACnF,MAAO,CAACF,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAkDvB,SAASG,EAAQhB,EAAGY,EAAGf,GACtB,OAdcgB,EAcDF,EAdIL,EAcMN,EAdHS,EAcMG,EAdHK,EAcMpB,GAZ5BqB,MAAMC,QAAQb,GACXO,EAAEP,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAChBO,EAAEP,EAAGG,EAAGQ,IACVG,IAAIhB,GALP,IAAeS,EAAGP,EAAGG,EAAGQ,QCrHT,CACdI,GAAI,aACJC,aAAaC,EAAOC,GACnB,MAAMC,KAACA,EAAO,UAASC,QAAEA,GAAU,GAAQF,EAE3C,IAAKE,EACJ,OAGD,MAAMC,EArBR,YACC,MAAMC,EAXP,kBACO,EACN,IAAK,IAAIC,EAAI,EAAGA,EAAI,GAAIA,IAAK,CAC5B,MAAMC,EAAI,GAAKD,EACf,IAAK,IAAIE,EAAI,EAAGA,GAAKD,EAAGC,GAAK,QACtBA,EAAID,GAMAE,GACZ,IAAIhC,EAAI4B,EAAIK,OACZ,MAAQjC,EAAEkC,MAAM,CACf,IAAIC,EAAMnB,EAAQf,KAAKL,MAAgB,IAAVI,EAAEoC,OAAc,GAAK,SAC5C,CAACC,WAAYhC,EAAU,CAACE,EAAG4B,EAAI,GAAI3B,EAAG2B,EAAI,GAAI1B,EAAG0B,EAAI,GAAI7B,EAAG,MAAOgC,OAAQjC,EAAU,CAACE,EAAG4B,EAAI,GAAI3B,EAAG2B,EAAI,GAAI1B,EAAG0B,EAAI,GAAI7B,EAAG,OAChI6B,EAAMnB,EAAQf,KAAKL,MAAgB,IAAVI,EAAEoC,OAAc,GAAK,SACxC,CAACC,WAAYhC,EAAU,CAACE,EAAG4B,EAAI,GAAI3B,EAAG2B,EAAI,GAAI1B,EAAG0B,EAAI,GAAI7B,EAAG,MAAOgC,OAAQjC,EAAU,CAACE,EAAG4B,EAAI,GAAI3B,EAAG2B,EAAI,GAAI1B,EAAG0B,EAAI,GAAI7B,EAAG,OAChIN,EAAI4B,EAAIK,QAaMM,GAEdhB,EAAMiB,KAAKC,SAASC,QAAQC,IAC3B,GAAa,YAATlB,EAAoB,CACvB,MAAMR,EAAIU,EAAMM,OAAOG,MACvBO,EAAQC,gBAAkB3B,EAAEoB,WAC5BM,EAAQE,YAAc5B,EAAEqB,WAClB,CACN,MAAMD,EAAa,GACbC,EAAS,GAEfK,EAAQH,KAAKpB,IAAI,KAChB,MAAMH,EAAIU,EAAMM,OAAOG,MACvBC,EAAWS,KAAK7B,EAAEoB,YAClBC,EAAOQ,KAAK7B,EAAEqB,UAEfK,EAAQC,gBAAkBP,EAC1BM,EAAQE,YAAcP"}
|
package/rollup.config.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/* eslint-env es6 */
|
|
2
|
-
|
|
3
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
4
|
-
import {terser} from 'rollup-plugin-terser';
|
|
5
|
-
import {name, version, homepage, main} from './package.json';
|
|
6
|
-
|
|
7
|
-
const input = 'src/index.js';
|
|
8
|
-
|
|
9
|
-
const banner = `/*!
|
|
10
|
-
* ${name} v${version}
|
|
11
|
-
* ${homepage}
|
|
12
|
-
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Jukka Kurkela
|
|
13
|
-
* Released under the MIT License
|
|
14
|
-
*/`;
|
|
15
|
-
|
|
16
|
-
export default [
|
|
17
|
-
{
|
|
18
|
-
input,
|
|
19
|
-
plugins: [
|
|
20
|
-
resolve()
|
|
21
|
-
],
|
|
22
|
-
output: {
|
|
23
|
-
name,
|
|
24
|
-
file: main,
|
|
25
|
-
banner,
|
|
26
|
-
format: 'umd',
|
|
27
|
-
indent: false
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
input,
|
|
32
|
-
plugins: [
|
|
33
|
-
resolve(),
|
|
34
|
-
terser({
|
|
35
|
-
output: {
|
|
36
|
-
preamble: banner
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
],
|
|
40
|
-
output: {
|
|
41
|
-
name,
|
|
42
|
-
file: main.replace('.js', '.min.js'),
|
|
43
|
-
format: 'umd',
|
|
44
|
-
sourcemap: true,
|
|
45
|
-
indent: false
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
input,
|
|
50
|
-
plugins: [
|
|
51
|
-
resolve()
|
|
52
|
-
],
|
|
53
|
-
output: {
|
|
54
|
-
name,
|
|
55
|
-
file: main.replace('.js', '.esm.js'),
|
|
56
|
-
banner,
|
|
57
|
-
format: 'esm',
|
|
58
|
-
indent: false
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
];
|
package/sample.png
DELETED
|
Binary file
|
package/samples/bar.html
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Matrix Chart on linear scale</title>
|
|
5
|
-
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-alpha/dist/Chart.js"></script>
|
|
6
|
-
<script src="utils.js"></script>
|
|
7
|
-
<link rel="stylesheet" type="text/css" href="style.css"></link>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="canvas-holder">
|
|
11
|
-
<canvas id="chart-area" width="800" height="400"></canvas>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
/* eslint-disable no-undef */
|
|
17
|
-
const rand = () => Math.random() * 100;
|
|
18
|
-
|
|
19
|
-
Utils.load(() => {
|
|
20
|
-
const ctx = document.getElementById('chart-area').getContext('2d');
|
|
21
|
-
window.myBar = new Chart(ctx, {
|
|
22
|
-
type: 'bar',
|
|
23
|
-
data: {
|
|
24
|
-
labels: ['color'],
|
|
25
|
-
datasets: [{
|
|
26
|
-
label: 'Bar 1',
|
|
27
|
-
data: [rand()],
|
|
28
|
-
}, {
|
|
29
|
-
label: 'Bar 2',
|
|
30
|
-
data: [rand()],
|
|
31
|
-
}, {
|
|
32
|
-
label: 'Bar 3',
|
|
33
|
-
data: [rand()],
|
|
34
|
-
}, {
|
|
35
|
-
label: 'Bar 4',
|
|
36
|
-
data: [rand()],
|
|
37
|
-
}, {
|
|
38
|
-
label: 'Bar 5',
|
|
39
|
-
data: [rand()],
|
|
40
|
-
}, {
|
|
41
|
-
label: 'Bar 6',
|
|
42
|
-
data: [rand()],
|
|
43
|
-
}, {
|
|
44
|
-
label: 'Bar 7',
|
|
45
|
-
data: [rand()],
|
|
46
|
-
}, {
|
|
47
|
-
label: 'Bar 8',
|
|
48
|
-
data: [rand()],
|
|
49
|
-
}, {
|
|
50
|
-
label: 'Bar 9',
|
|
51
|
-
data: [rand()],
|
|
52
|
-
}, {
|
|
53
|
-
label: 'Bar 10',
|
|
54
|
-
data: [rand()],
|
|
55
|
-
}, {
|
|
56
|
-
label: 'Bar 11',
|
|
57
|
-
data: [rand()],
|
|
58
|
-
}, {
|
|
59
|
-
label: 'Bar 12',
|
|
60
|
-
data: [rand()],
|
|
61
|
-
}, {
|
|
62
|
-
label: 'Bar 13',
|
|
63
|
-
data: [rand()],
|
|
64
|
-
}, {
|
|
65
|
-
label: 'Bar 14',
|
|
66
|
-
data: [rand()],
|
|
67
|
-
}, {
|
|
68
|
-
label: 'Bar 15',
|
|
69
|
-
data: [rand()],
|
|
70
|
-
}, {
|
|
71
|
-
label: 'Bar 16',
|
|
72
|
-
data: [rand()],
|
|
73
|
-
}, {
|
|
74
|
-
label: 'Bar 17',
|
|
75
|
-
data: [rand()],
|
|
76
|
-
}, {
|
|
77
|
-
label: 'Bar 18',
|
|
78
|
-
data: [rand()],
|
|
79
|
-
}, {
|
|
80
|
-
label: 'Bar 19',
|
|
81
|
-
data: [rand()],
|
|
82
|
-
}, {
|
|
83
|
-
label: 'Bar 20',
|
|
84
|
-
data: [rand()],
|
|
85
|
-
}]
|
|
86
|
-
},
|
|
87
|
-
options: {
|
|
88
|
-
elements: {
|
|
89
|
-
rectangle: {
|
|
90
|
-
borderWidth: 2
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
plugins: [
|
|
95
|
-
window['chartjs-plugin-autocolors']
|
|
96
|
-
]
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
</script>
|
|
100
|
-
</body>
|
|
101
|
-
</html>
|
package/samples/style.css
DELETED
package/samples/utils.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
(function(Utils) {
|
|
4
|
-
const localUrl = '../dist/chartjs-plugin-autocolors.js';
|
|
5
|
-
const remoteUrl = 'https://cdn.jsdelivr.net/npm/chartjs-chart-matrix/dist/chartjs-plugin-autocolors.js';
|
|
6
|
-
|
|
7
|
-
function addScript(url, done, error) {
|
|
8
|
-
const head = document.getElementsByTagName('head')[0];
|
|
9
|
-
const script = document.createElement('script');
|
|
10
|
-
script.type = 'text/javascript';
|
|
11
|
-
script.onreadystatechange = function() {
|
|
12
|
-
if (this.readyState === 'complete') {
|
|
13
|
-
done();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
script.onload = done;
|
|
17
|
-
script.onerror = error;
|
|
18
|
-
script.src = url;
|
|
19
|
-
head.appendChild(script);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function loadError() {
|
|
24
|
-
const msg = document.createTextNode('Error loading chartjs-plugin-autocolors');
|
|
25
|
-
document.body.appendChild(msg);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Utils.load = function(done) {
|
|
30
|
-
addScript(localUrl, done, (event) => {
|
|
31
|
-
event.preventDefault();
|
|
32
|
-
event.stopPropagation();
|
|
33
|
-
addScript(remoteUrl, done, loadError);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
}(window.Utils = window.Utils || {}));
|
package/src/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {hsv2rgb, rgbString} from '@kurkle/color';
|
|
2
|
-
|
|
3
|
-
function* hueGen() {
|
|
4
|
-
yield 0;
|
|
5
|
-
for (let i = 1; i < 10; i++) {
|
|
6
|
-
const d = 1 << i;
|
|
7
|
-
for (let j = 1; j <= d; j += 2) {
|
|
8
|
-
yield j / d;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function* colorGen() {
|
|
14
|
-
const hue = hueGen();
|
|
15
|
-
let h = hue.next();
|
|
16
|
-
while (!h.done) {
|
|
17
|
-
let rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.8);
|
|
18
|
-
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
19
|
-
rgb = hsv2rgb(Math.round(h.value * 360), 0.6, 0.5);
|
|
20
|
-
yield {background: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 192}), border: rgbString({r: rgb[0], g: rgb[1], b: rgb[2], a: 144})};
|
|
21
|
-
h = hue.next();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default {
|
|
26
|
-
id: 'autocolors',
|
|
27
|
-
beforeUpdate(chart, options) {
|
|
28
|
-
const {mode = 'dataset', enabled = true} = options;
|
|
29
|
-
|
|
30
|
-
if (!enabled) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const color = colorGen();
|
|
35
|
-
|
|
36
|
-
chart.data.datasets.forEach(dataset => {
|
|
37
|
-
if (mode === 'dataset') {
|
|
38
|
-
const c = color.next().value;
|
|
39
|
-
dataset.backgroundColor = c.background;
|
|
40
|
-
dataset.borderColor = c.border;
|
|
41
|
-
} else {
|
|
42
|
-
const background = [];
|
|
43
|
-
const border = [];
|
|
44
|
-
// eslint-disable-next-line array-callback-return
|
|
45
|
-
dataset.data.map(() => {
|
|
46
|
-
const c = color.next().value;
|
|
47
|
-
background.push(c.background);
|
|
48
|
-
border.push(c.border);
|
|
49
|
-
});
|
|
50
|
-
dataset.backgroundColor = background;
|
|
51
|
-
dataset.borderColor = border;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|