]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Make getHoverColor() return the original value if it is CanvasGradient (#5865)
authorAkihiko Kusanagi <nagi@nagi-p.com>
Wed, 28 Nov 2018 00:54:03 +0000 (08:54 +0800)
committerEvert Timberg <evert.timberg+github@gmail.com>
Wed, 28 Nov 2018 00:54:03 +0000 (19:54 -0500)
src/core/core.helpers.js
test/specs/core.helpers.tests.js

index 3b1eca5edb31cc137f70c14ea89c9beeb9b93470..ca8a7d20c3860a45957a79b9816517eefeb610b2 100644 (file)
@@ -647,7 +647,7 @@ module.exports = function() {
 
        helpers.getHoverColor = function(colorValue) {
                /* global CanvasPattern */
-               return (colorValue instanceof CanvasPattern) ?
+               return (colorValue instanceof CanvasPattern || colorValue instanceof CanvasGradient) ?
                        colorValue :
                        helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
        };
index 70f0981df0ec63905d78473bc5f24760ab36efc0..796148aaf6c534f6f78afc09ef865ff24e5c98d4 100644 (file)
@@ -848,6 +848,13 @@ describe('Core helper tests', function() {
                        };
                });
 
+               it('should return a CanvasGradient when called with a CanvasGradient', function() {
+                       var context = document.createElement('canvas').getContext('2d');
+                       var gradient = context.createLinearGradient(0, 1, 2, 3);
+
+                       expect(helpers.getHoverColor(gradient) instanceof CanvasGradient).toBe(true);
+               });
+
                it('should return a modified version of color when called with a color', function() {
                        var originalColorRGB = 'rgb(70, 191, 189)';