Home Forums Chart Support Pie chart empty if value 0

Pie chart empty if value 0

Viewing 2 posts - 1 through 2 (of 2 total)
  • #33804

    If the pie chart is having all the values as 0 then it shows nothing (empty white space)

    JSFiddle Live Example:
    https://jsfiddle.net/zc84thqg/

    Below JSFiddle example show how 0 value is shown in HighCharts
    https://jsfiddle.net/2gv5t4x8/

    #33822

    @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.

    Pie Chart with 0 Y-Values

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.