mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Switch from chartjs-color to @kurkle/color (#7059)
This commit is contained in:
parent
795c86e95b
commit
fa79eb8797
31
package-lock.json
generated
31
package-lock.json
generated
@ -779,6 +779,11 @@
|
||||
"to-fast-properties": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@kurkle/color": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.1.1.tgz",
|
||||
"integrity": "sha512-rpgJFEVJQNwCLSPiBbSSzR3ujRFXuwTRJEzYEto5/L5hsvEzoEHq0M72A6GJC5tWO/CF+tlS5Ii9hUb+Geiu1A=="
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -2199,23 +2204,6 @@
|
||||
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
|
||||
"dev": true
|
||||
},
|
||||
"chartjs-color": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chartjs-color/-/chartjs-color-2.4.1.tgz",
|
||||
"integrity": "sha512-haqOg1+Yebys/Ts/9bLo/BqUcONQOdr/hoEr2LLTRl6C5LXctUdHxsCYfvQVg5JIxITrfCNUDr4ntqmQk9+/0w==",
|
||||
"requires": {
|
||||
"chartjs-color-string": "^0.6.0",
|
||||
"color-convert": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"chartjs-color-string": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz",
|
||||
"integrity": "sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A==",
|
||||
"requires": {
|
||||
"color-name": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "2.1.8",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
|
||||
@ -2439,6 +2427,7 @@
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
},
|
||||
@ -2446,15 +2435,11 @@
|
||||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
||||
},
|
||||
"color-support": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
|
||||
|
||||
@ -75,6 +75,6 @@
|
||||
"yargs": "^14.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chartjs-color": "^2.1.0"
|
||||
"@kurkle/color": "^0.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ const interpolators = {
|
||||
var c0 = helpers.color(from || transparent);
|
||||
var c1 = c0.valid && helpers.color(to || transparent);
|
||||
return c1 && c1.valid
|
||||
? c1.mix(c0, factor).rgbaString()
|
||||
? c1.mix(c0, factor).hexString()
|
||||
: to;
|
||||
},
|
||||
number: function(from, to, factor) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import color from 'chartjs-color';
|
||||
import color from '@kurkle/color';
|
||||
|
||||
import * as coreHelpers from './helpers.core';
|
||||
import * as canvas from './helpers.canvas';
|
||||
@ -49,6 +49,6 @@ export default {
|
||||
getHoverColor: function(colorValue) {
|
||||
return (colorValue instanceof CanvasPattern || colorValue instanceof CanvasGradient) ?
|
||||
colorValue :
|
||||
colorHelper(colorValue).saturate(0.5).darken(0.1).rgbString();
|
||||
colorHelper(colorValue).saturate(0.5).darken(0.1).hexString();
|
||||
}
|
||||
};
|
||||
|
||||
@ -1279,8 +1279,8 @@ describe('Chart.controllers.bar', function() {
|
||||
var bar = meta.data[0];
|
||||
|
||||
meta.controller.setHoverStyle(bar, 1, 0);
|
||||
expect(bar.options.backgroundColor).toBe('rgb(230, 0, 0)');
|
||||
expect(bar.options.borderColor).toBe('rgb(0, 0, 230)');
|
||||
expect(bar.options.backgroundColor).toBe('#E60000');
|
||||
expect(bar.options.borderColor).toBe('#0000E6');
|
||||
expect(bar.options.borderWidth).toBe(2);
|
||||
|
||||
// Set a dataset style
|
||||
|
||||
@ -293,8 +293,8 @@ describe('Chart.controllers.bubble', function() {
|
||||
var point = chart.getDatasetMeta(0).data[0];
|
||||
|
||||
afterEvent(chart, 'mousemove', function() {
|
||||
expect(point.options.backgroundColor).toBe('rgb(49, 135, 221)');
|
||||
expect(point.options.borderColor).toBe('rgb(22, 89, 156)');
|
||||
expect(point.options.backgroundColor).toBe('#3187DD');
|
||||
expect(point.options.borderColor).toBe('#175A9D');
|
||||
expect(point.options.borderWidth).toBe(1);
|
||||
expect(point.options.radius).toBe(20 + 4);
|
||||
|
||||
|
||||
@ -352,8 +352,8 @@ describe('Chart.controllers.doughnut', function() {
|
||||
var arc = chart.getDatasetMeta(0).data[0];
|
||||
|
||||
afterEvent(chart, 'mousemove', function() {
|
||||
expect(arc.options.backgroundColor).toBe('rgb(49, 135, 221)');
|
||||
expect(arc.options.borderColor).toBe('rgb(22, 89, 156)');
|
||||
expect(arc.options.backgroundColor).toBe('#3187DD');
|
||||
expect(arc.options.borderColor).toBe('#175A9D');
|
||||
expect(arc.options.borderWidth).toBe(2);
|
||||
|
||||
afterEvent(chart, 'mouseout', function() {
|
||||
|
||||
@ -795,8 +795,8 @@ describe('Chart.controllers.line', function() {
|
||||
var point = chart.getDatasetMeta(0).data[0];
|
||||
|
||||
afterEvent(chart, 'mousemove', function() {
|
||||
expect(point.options.backgroundColor).toBe('rgb(49, 135, 221)');
|
||||
expect(point.options.borderColor).toBe('rgb(22, 89, 156)');
|
||||
expect(point.options.backgroundColor).toBe('#3187DD');
|
||||
expect(point.options.borderColor).toBe('#175A9D');
|
||||
expect(point.options.borderWidth).toBe(1);
|
||||
expect(point.options.radius).toBe(4);
|
||||
|
||||
|
||||
@ -265,8 +265,8 @@ describe('Chart.controllers.polarArea', function() {
|
||||
var arc = chart.getDatasetMeta(0).data[0];
|
||||
|
||||
afterEvent(chart, 'mousemove', function() {
|
||||
expect(arc.options.backgroundColor).toBe('rgb(49, 135, 221)');
|
||||
expect(arc.options.borderColor).toBe('rgb(22, 89, 156)');
|
||||
expect(arc.options.backgroundColor).toBe('#3187DD');
|
||||
expect(arc.options.borderColor).toBe('#175A9D');
|
||||
expect(arc.options.borderWidth).toBe(2);
|
||||
|
||||
afterEvent(chart, 'mouseout', function() {
|
||||
|
||||
@ -257,8 +257,8 @@ describe('Chart.controllers.radar', function() {
|
||||
var point = chart.getDatasetMeta(0).data[0];
|
||||
|
||||
afterEvent(chart, 'mousemove', function() {
|
||||
expect(point.options.backgroundColor).toBe('rgb(49, 135, 221)');
|
||||
expect(point.options.borderColor).toBe('rgb(22, 89, 156)');
|
||||
expect(point.options.backgroundColor).toBe('#3187DD');
|
||||
expect(point.options.borderColor).toBe('#175A9D');
|
||||
expect(point.options.borderWidth).toBe(1);
|
||||
expect(point.options.radius).toBe(4);
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ describe('Core helper tests', function() {
|
||||
|
||||
describe('Color helper', function() {
|
||||
function isColorInstance(obj) {
|
||||
return typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'values') && Object.prototype.hasOwnProperty.call(obj.values, 'rgb');
|
||||
return typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'valid');
|
||||
}
|
||||
|
||||
it('should return a color when called with a color', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user