Pie charts get the selected pie id - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

Pie charts get the selected pie id

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>HighCharts Pie Test</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//from  w w  w  . j  av  a  2 s .  c  om
var chart;
point = null;
$(document).ready(function () {
    var data = [{ name: 'One', y: 10, id: 0 },{ name: 'Two', y: 10, id: 1 }];
    chart = new Highcharts.Chart(
    {
       series:[
          {
             "data": data,
              type: 'pie',
              animation: false,
              point:{
                  events:{
                      click: function (event) {
                          console.log(this.id);
                      }
                  }
              }
          }
       ],
       "chart":{
          "renderTo":"container"
       },
    });
});
    });

      </script> 
   </head> 
   <body> 
      <div id="container" style="width: 320px; height: 200px"></div>  
   </body>
</html>

Related Tutorials