From: Tom Loudon Date: Mon, 9 May 2016 06:24:32 +0000 (+0100) Subject: Removed 'background' from hover color helper name. X-Git-Tag: v2.1.3~3^2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=170fdab6a608b69594b60fa1fde3e3afc8b0ff2b;p=thirdparty%2FChart.js.git Removed 'background' from hover color helper name. Patterns could be used for style attributes other than background e.g. stroke. Updates chartjs/Chart.js#1323 --- diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 4039bcf55..ede9d9ba9 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -250,7 +250,7 @@ module.exports = function(Chart) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; - arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverBackgroundColor(arc._model.backgroundColor)); + arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverColor(arc._model.backgroundColor)); arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, arc._model.borderWidth); }, diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 3f09d5cfb..60673d8fa 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -943,9 +943,9 @@ module.exports = function(Chart) { fn.apply(_tArg, args); } }; - helpers.getHoverBackgroundColor = function(backgroundColor) { - return (backgroundColor instanceof CanvasPattern) ? - backgroundColor : - helpers.color(backgroundColor).saturate(0.5).darken(0.1).rgbString(); + helpers.getHoverColor = function(color) { + return (color instanceof CanvasPattern) ? + color : + helpers.color(color).saturate(0.5).darken(0.1).rgbString(); }; }; diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js index bea31e1ea..2aa6c37e1 100644 --- a/test/core.helpers.tests.js +++ b/test/core.helpers.tests.js @@ -684,8 +684,8 @@ describe('Core helper tests', function() { }); }); - describe('Background canvas hover helper', function() { - it('should return a CanvasPattern backgroundColor when called with a CanvasPattern', function(done) { + describe('Background hover color helper', function() { + it('should return a CanvasPattern when called with a CanvasPattern', function(done) { var dots = new Image(); dots.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAD1BMVEUAAAD///////////////+PQt5oAAAABXRSTlMAHlFhZsfk/BEAAAAqSURBVHgBY2BgZGJmYmSAAUYWEIDzmcBcJhiXGcxlRpPFrhdmMiqgvX0AcGIBEUAo6UAAAAAASUVORK5CYII='; dots.onload = function() { @@ -695,7 +695,7 @@ describe('Core helper tests', function() { var pattern = patternContext.createPattern(dots, 'repeat'); patternContext.fillStyle = pattern; - var backgroundColor = helpers.getHoverBackgroundColor(chartContext.createPattern(patternCanvas, 'repeat')); + var backgroundColor = helpers.getHoverColor(chartContext.createPattern(patternCanvas, 'repeat')); expect(backgroundColor instanceof CanvasPattern).toBe(true); @@ -703,10 +703,10 @@ describe('Core helper tests', function() { } }); - it('should return a modified version of backgroundColor when called with a color', function() { + it('should return a modified version of color when called with a color', function() { var originalColorRGB = 'rgb(70, 191, 189)'; - expect(helpers.getHoverBackgroundColor('#46BFBD')).not.toEqual(originalColorRGB); + expect(helpers.getHoverColor('#46BFBD')).not.toEqual(originalColorRGB); }); }); });