showing 0 data correctly for pie chart - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

showing 0 data correctly for pie chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> 
      <script type="text/javascript">
Highcharts.chart('container', {
  chart: {//  ww w.  ja  va  2  s.  c om
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false,
    type: 'pie',
    events: {
      load: function() {
        this.series[0].points.forEach(function(p) {
          if (!p.y) {
            p.graphic.destroy();
          }
        });
      }
    }
  },
  title: {
    text: 'Browser market shares January, 2015 to May, 2015'
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels: {
        enabled: true,
        format: '<b>{point.name}</b>: {point.percentage:.1f} %',
        style: {
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
        }
      }
    }
  },
  series: [{
    name: 'Brands',
    colors: ['#3366CC', '#FF9900', '#A9A9A9', '#109618'],
    colorByPoint: true,
    data: [{
      name: 'Check1',
      y: 100
    }, {
      name: 'Check2',
      y: 0
    }]
  }]
});

      </script>  
   </body>
</html>

Related Tutorials