Home › Forums › Chart Support › Pie chart empty if value 0 › Reply To: Pie chart empty if value 0
@kpandey017,
It is not possible to show pie slices when all the dataPoints has 0 value as of now. However, you can achieve similar functionality by changing chart type to doughnut, pushing one extra dataPoint with non-zero y-value and setting innerRadius to 99% as shown in the code snippet below
function checkForZeroDps(chart) { var isDpsZero = false; for(var i = 0; i < chart.options.data[0].dataPoints.length; i++) { if(chart.options.data[0].dataPoints[i].y === 0) { isDpsZero = true; } } if(isDpsZero) { chart.options.data[0].type = "doughnut"; chart.options.data[0].innerRadius = "99%"; chart.options.data[0].dataPoints.push({ y: 0.000001, indexLabel: " ", indexLabelLineThickness: 0, toolTipContent: null }); } }
Please take a look at this JSFiddle for complete code.
—- Manoj Mohan Team CanvasJS