From: Evert Timberg Date: Sat, 7 Jan 2017 02:41:10 +0000 (-0500) Subject: when the cutoutPercentage is 0, the inner radius should be 0 X-Git-Tag: v2.5.0~1^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e9b9cf46d452dfbfb2fa19a9cd362d4405abfdc;p=thirdparty%2FChart.js.git when the cutoutPercentage is 0, the inner radius should be 0 --- diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 3dcd33e9f..70ee22e18 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -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; diff --git a/test/controller.doughnut.tests.js b/test/controller.doughnut.tests.js index d9319bb80..f4c0c959e 100644 --- a/test/controller.doughnut.tests.js +++ b/test/controller.doughnut.tests.js @@ -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',