Skip to content

Commit 9014f43

Browse files
nagixetimberg
authored andcommitted
Make getHoverColor() return the original value if it is CanvasGradient (chartjs#5865)
1 parent 8e35eef commit 9014f43

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/core/core.helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ module.exports = function() {
647647

648648
helpers.getHoverColor = function(colorValue) {
649649
/* global CanvasPattern */
650-
return (colorValue instanceof CanvasPattern) ?
650+
return (colorValue instanceof CanvasPattern || colorValue instanceof CanvasGradient) ?
651651
colorValue :
652652
helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
653653
};

test/specs/core.helpers.tests.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,13 @@ describe('Core helper tests', function() {
848848
};
849849
});
850850

851+
it('should return a CanvasGradient when called with a CanvasGradient', function() {
852+
var context = document.createElement('canvas').getContext('2d');
853+
var gradient = context.createLinearGradient(0, 1, 2, 3);
854+
855+
expect(helpers.getHoverColor(gradient) instanceof CanvasGradient).toBe(true);
856+
});
857+
851858
it('should return a modified version of color when called with a color', function() {
852859
var originalColorRGB = 'rgb(70, 191, 189)';
853860

0 commit comments

Comments
 (0)