From: Evert Timberg Date: Tue, 31 May 2016 01:33:11 +0000 (-0400) Subject: Reduce duplicated code in doughnut controller X-Git-Tag: v2.1.5~23^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5167cc42d397491247e406253afd006ba6b33b5;p=thirdparty%2FChart.js.git Reduce duplicated code in doughnut controller --- diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 9f7cd2f2c..423d767a1 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -220,10 +220,8 @@ module.exports = function(Chart) { }); var model = arc._model; - model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(dataset.backgroundColor, index, arcOpts.backgroundColor); - model.hoverBackgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : valueAtIndexOrDefault(dataset.hoverBackgroundColor, index, arcOpts.hoverBackgroundColor); - model.borderWidth = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(dataset.borderWidth, index, arcOpts.borderWidth); - model.borderColor = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(dataset.borderColor, index, arcOpts.borderColor); + // Resets the visual styles + this.removeHoverStyle(arc); // Set correct angles if not resetting if (!reset || !animationOpts.animateRotate) { diff --git a/test/controller.doughnut.tests.js b/test/controller.doughnut.tests.js index 96c9501a9..945a2af5c 100644 --- a/test/controller.doughnut.tests.js +++ b/test/controller.doughnut.tests.js @@ -75,8 +75,7 @@ describe('Doughnut controller tests', function() { arc: { backgroundColor: 'rgb(255, 0, 0)', borderColor: 'rgb(0, 0, 255)', - borderWidth: 2, - hoverBackgroundColor: 'rgb(255, 255, 255)' + borderWidth: 2 } } } @@ -102,7 +101,6 @@ describe('Doughnut controller tests', function() { startAngle: Math.PI * -0.5, endAngle: Math.PI * -0.5, label: chart.data.labels[i], - hoverBackgroundColor: 'rgb(255, 255, 255)', backgroundColor: 'rgb(255, 0, 0)', borderColor: 'rgb(0, 0, 255)', borderWidth: 2 @@ -125,7 +123,6 @@ describe('Doughnut controller tests', function() { expect(meta.data[i]._model.endAngle).toBeCloseTo(expected.e, 8); expect(meta.data[i]._model).toEqual(jasmine.objectContaining({ label: chart.data.labels[i], - hoverBackgroundColor: 'rgb(255, 255, 255)', backgroundColor: 'rgb(255, 0, 0)', borderColor: 'rgb(0, 0, 255)', borderWidth: 2 @@ -173,8 +170,7 @@ describe('Doughnut controller tests', function() { arc: { backgroundColor: 'rgb(255, 0, 0)', borderColor: 'rgb(0, 0, 255)', - borderWidth: 2, - hoverBackgroundColor: 'rgb(255, 255, 255)' + borderWidth: 2 } } }