Search code examples
highchartspie-chart

Highcharts make pie chart show 0 data


When I have the following data supplied to Pie chart: [[0],[0],[0]], the chart is empty.

However, I want to make the pie show three slices, with each percentage distribution equal to 33.3%

I know it is better to use bar / column chart in this case, however I have this edge case where I need to show 0 data in Pie chart


Solution

  • Workaround:

    Set some nonzero value and add isZero flag for every point. Then use this flag in tooltip.pointFormatter:

    tooltip: {
      pointFormatter: function() {
        return "<span style='color:" + this.color + "'>\u25CF</span>" + this.series.name + ": <b>" + (this.options.isZero ? 0 : this.y) + "</b><br/>";
      } 
    }
    

    This will cause that your points will be visible and 0 will be printed in tooltip if the hovered point has isZero flag set to true.

    Live demo: http://jsfiddle.net/BlackLabel/52a1xh99/