perform an action on Pie chart's legend click ? - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

perform an action on Pie chart's legend click ?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/* w w w .j  a  va  2  s  . c  o  m*/
    $('#container').highcharts({
        title:{
            useHTML:true,
            text: '<div id="title">default title</div>'
        },
        plotOptions: {
            series: {
                events: {
                    legendItemClick: function(event) {
                        console.log(this);
                        $('#title').html(this.name);
                    }
                }
            }
        },
        series: [{
            name: 'aaaa',
            data: [6,5,3,2,1]
        },{
            name: 'bbb',
            data: [6,4,3,7,9]
        },{
            name: 'ccc',
            data: [2,3,2,1,5]
        },{
            name: 'dddd',
            data: [2,3,2,1,3]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials