]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Reduce duplicated code in doughnut controller
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 31 May 2016 01:33:11 +0000 (21:33 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 31 May 2016 01:33:11 +0000 (21:33 -0400)
src/controllers/controller.doughnut.js
test/controller.doughnut.tests.js

index 9f7cd2f2c8d1babde5f74f0fb68836c1f557c74a..423d767a16a0b3ccbc0c9b53a25957bef0075cce 100644 (file)
@@ -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) {
index 96c9501a99185321ad747585c1e53f8529c56a85..945a2af5c7e6bb6ef9baa2bf8392e06840bf6ebb 100644 (file)
@@ -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
                                        }
                                }
                        }