chartjs-plugin-autocolors 0.0.6 → 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
@@ -17,7 +17,7 @@ This plugin requires Chart.js 3.0.0 or later. Could work with v2, but it is not
17
17
  NPM:
18
18
 
19
19
  ```bash
20
- npm i --save-dev chartjs-plugin-autocolors
20
+ npm i --save chartjs-plugin-autocolors
21
21
  ```
22
22
 
23
23
  CDN:
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * chartjs-plugin-autocolors v0.0.6
2
+ * chartjs-plugin-autocolors v0.0.7
3
3
  * https://github.com/kurkle/chartjs-plugin-autocolors#readme
4
4
  * (c) 2022 Jukka Kurkela
5
5
  * Released under the MIT License
@@ -86,10 +86,12 @@ var index = {
86
86
  return;
87
87
  }
88
88
 
89
- const color = colorGen();
90
- if (options.offset) {
91
- for (let i = 0; i < options.offset; i++) {
92
- color.next();
89
+ if (!chart._autocolor) {
90
+ chart._autocolor = colorGen();
91
+ if (options.offset) {
92
+ for (let i = 0; i < options.offset; i++) {
93
+ chart._autocolor.next();
94
+ }
93
95
  }
94
96
  }
95
97
 
@@ -98,13 +100,13 @@ var index = {
98
100
  continue;
99
101
  }
100
102
  if (mode === 'dataset') {
101
- const c = getNext(color, customize, {chart, datasetIndex: dataset.index});
103
+ const c = getNext(chart._autocolor, customize, {chart, datasetIndex: dataset.index});
102
104
  setColors(dataset, c.background, c.border);
103
105
  } else {
104
106
  const background = [];
105
107
  const border = [];
106
108
  for (let i = 0; i < dataset.data.length; i++) {
107
- const c = getNext(color, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
109
+ const c = getNext(chart._autocolor, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
108
110
  background.push(c.background);
109
111
  border.push(c.border);
110
112
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * chartjs-plugin-autocolors v0.0.6
2
+ * chartjs-plugin-autocolors v0.0.7
3
3
  * https://github.com/kurkle/chartjs-plugin-autocolors#readme
4
4
  * (c) 2022 Jukka Kurkela
5
5
  * Released under the MIT License
@@ -92,10 +92,12 @@ var index = {
92
92
  return;
93
93
  }
94
94
 
95
- const color = colorGen();
96
- if (options.offset) {
97
- for (let i = 0; i < options.offset; i++) {
98
- color.next();
95
+ if (!chart._autocolor) {
96
+ chart._autocolor = colorGen();
97
+ if (options.offset) {
98
+ for (let i = 0; i < options.offset; i++) {
99
+ chart._autocolor.next();
100
+ }
99
101
  }
100
102
  }
101
103
 
@@ -104,13 +106,13 @@ var index = {
104
106
  continue;
105
107
  }
106
108
  if (mode === 'dataset') {
107
- const c = getNext(color, customize, {chart, datasetIndex: dataset.index});
109
+ const c = getNext(chart._autocolor, customize, {chart, datasetIndex: dataset.index});
108
110
  setColors(dataset, c.background, c.border);
109
111
  } else {
110
112
  const background = [];
111
113
  const border = [];
112
114
  for (let i = 0; i < dataset.data.length; i++) {
113
- const c = getNext(color, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
115
+ const c = getNext(chart._autocolor, customize, {chart, datasetIndex: dataset.index, dataIndex: i});
114
116
  background.push(c.background);
115
117
  border.push(c.border);
116
118
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * chartjs-plugin-autocolors v0.0.6
2
+ * chartjs-plugin-autocolors v0.0.7
3
3
  * https://github.com/kurkle/chartjs-plugin-autocolors#readme
4
4
  * (c) 2022 Jukka Kurkela
5
5
  * Released under the MIT License
@@ -10,5 +10,5 @@
10
10
  * https://github.com/kurkle/color#readme
11
11
  * (c) 2022 Jukka Kurkela
12
12
  * Released under the MIT License
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(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 r(o,t,r){return a=e,d=o,u=t,c=r,(Array.isArray(d)?a(d[0],d[1],d[2]):a(d,u,c)).map(n);var a,d,u,c}function a(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 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:e="dataset",enabled:c=!0,customize:f}=n;if(!c)return;const i=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=r(Math.round(360*t.value),.6,.8);yield{background:a({r:n[0],g:n[1],b:n[2],a:192}),border:a({r:n[0],g:n[1],b:n[2],a:144})},n=r(Math.round(360*t.value),.6,.5),yield{background:a({r:n[0],g:n[1],b:n[2],a:192}),border:a({r:n[0],g:n[1],b:n[2],a:144})},t=o.next()}}();if(n.offset)for(let o=0;o<n.offset;o++)i.next();for(const t of o.data.datasets)if(!t.backgroundColor||!t.borderColor)if("dataset"===e){const n=u(i,f,{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(i,f,{chart:o,datasetIndex:t.index,dataIndex:r});n.push(a.background),e.push(a.border)}d(t,n,e)}}}}));
13
+ */function o(o){return o+.5|0}const t=(o,t,r)=>Math.max(Math.min(o,r),t);function r(r){return t(o(255*r),0,255)}function e(o,t,r){const e=(e,n=(e+o/60)%6)=>r-r*t*Math.max(Math.min(n,4-n,1),0);return[e(5),e(3),e(1)]}function n(o,t,n){return a=e,u=o,d=t,c=n,(Array.isArray(u)?a(u[0],u[1],u[2]):a(u,d,c)).map(r);var a,u,d,c}function a(r){return r&&(r.a<255?`rgba(${r.r}, ${r.g}, ${r.b}, ${function(r){return t(o(r/2.55)/100,0,1)}(r.a)})`:`rgb(${r.r}, ${r.g}, ${r.b})`)}function u(o,t,r){o.backgroundColor=o.backgroundColor||t,o.borderColor=o.borderColor||r}function d(o,t,r){const e=o.next().value;return"function"==typeof t?t(Object.assign({colors:e},r)):e}return{id:"autocolors",beforeUpdate(o,t,r){const{mode:e="dataset",enabled:c=!0,customize:f}=r;if(c){if(!o._autocolor&&(o._autocolor=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 r=n(Math.round(360*t.value),.6,.8);yield{background:a({r:r[0],g:r[1],b:r[2],a:192}),border:a({r:r[0],g:r[1],b:r[2],a:144})},r=n(Math.round(360*t.value),.6,.5),yield{background:a({r:r[0],g:r[1],b:r[2],a:192}),border:a({r:r[0],g:r[1],b:r[2],a:144})},t=o.next()}}(),r.offset))for(let t=0;t<r.offset;t++)o._autocolor.next();for(const t of o.data.datasets)if(!t.backgroundColor||!t.borderColor)if("dataset"===e){const r=d(o._autocolor,f,{chart:o,datasetIndex:t.index});u(t,r.background,r.border)}else{const r=[],e=[];for(let n=0;n<t.data.length;n++){const a=d(o._autocolor,f,{chart:o,datasetIndex:t.index,dataIndex:n});r.push(a.background),e.push(a.border)}u(t,r,e)}}}}}));
14
14
  //# sourceMappingURL=chartjs-plugin-autocolors.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chartjs-plugin-autocolors",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Automatic color generation for Chart.js",
5
5
  "main": "dist/chartjs-plugin-autocolors.js",
6
6
  "module": "dist/chartjs-plugin-autocolors.esm.js",
@@ -31,12 +31,12 @@
31
31
  "homepage": "https://github.com/kurkle/chartjs-plugin-autocolors#readme",
32
32
  "devDependencies": {
33
33
  "@kurkle/color": "^0.2.1",
34
- "@rollup/plugin-node-resolve": "^13.0.4",
34
+ "@rollup/plugin-node-resolve": "^14.1.0",
35
35
  "eslint": "^8.17.0",
36
36
  "eslint-config-chartjs": "^0.3.0",
37
37
  "eslint-plugin-es": "^4.1.0",
38
- "eslint-plugin-html": "^6.1.2",
39
- "eslint-plugin-markdown": "^2.2.0",
38
+ "eslint-plugin-html": "^7.1.0",
39
+ "eslint-plugin-markdown": "^3.0.0",
40
40
  "rollup": "^2.33.2",
41
41
  "rollup-plugin-terser": "^7.0.2"
42
42
  }