when the cutoutPercentage is 0, the inner radius should be 0

This commit is contained in:
Evert Timberg
2017-01-06 21:41:10 -05:00
parent 27b2e332c6
commit 9e9b9cf46d
2 changed files with 15 additions and 1 deletions

View 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;

View 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',