]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
when the cutoutPercentage is 0, the inner radius should be 0
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 7 Jan 2017 02:41:10 +0000 (21:41 -0500)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 15 Jan 2017 17:46:01 +0000 (12:46 -0500)
src/controllers/controller.doughnut.js
test/controller.doughnut.tests.js

index 3dcd33e9f63c6dbe89edee68adbfb073557b7f0b..70ee22e18419c69c824ad4643336f55b235b6acc 100644 (file)
@@ -183,7 +183,7 @@ module.exports = function(Chart) {
 
                        chart.borderWidth = me.getMaxBorderWidth(meta.data);
                        chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0);
-                       chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 1, 0);
+                       chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 0, 0);
                        chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
                        chart.offsetX = offset.x * chart.outerRadius;
                        chart.offsetY = offset.y * chart.outerRadius;
index d9319bb807a3d6dd0f653f13b7f7867e051baeac..f4c0c959e301e82119b8c279753091df5c5ed553 100644 (file)
@@ -40,6 +40,20 @@ describe('Doughnut controller tests', function() {
                expect(meta.data[3] instanceof Chart.elements.Arc).toBe(true);
        });
 
+       it('should set the innerRadius to 0 if the config option is 0', function() {
+               var chart = window.acquireChart({
+                       type: 'pie',
+                       data: {
+                               datasets: [{
+                                       data: [10, 15, 0, 4]
+                               }],
+                               labels: []
+                       }
+               });
+
+               expect(chart.innerRadius).toBe(0);
+       });
+
        it ('should reset and update elements', function() {
                var chart = window.acquireChart({
                        type: 'doughnut',