event onclick this.point.name - Javascript highcharts

Javascript examples for highcharts:Chart Point

Description

event onclick this.point.name

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <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">
$(function () {/* ww  w. j a va  2 s.c  o  m*/
    $('#container').highcharts({
        chart: {
            type: 'pie'
        },
        tooltip: {
            formatter: function (e) {
                return this.point.name;
            }
        },
        plotOptions: {
            pie: {
                dataLabels: {
                    formatter: function (e) {
                        return this.point.name;
                    }
                }
            },
            series: {
                point: {
                    events: {
                        click: function() {
                            console.log(this.name);
                        }
                    }
                }
            }
        },
        series: [{
            name: 'Brands',
            colorByPoint: true,
            data: [{
                name: 'Microsoft Internet Explorer',
                y: 56.33
            }, {
                name: 'Chrome',
                y: 24.03,
                sliced: true,
                selected: true
            }, {
                name: 'Firefox',
                y: 10.38
            }, {
                name: 'Safari',
                y: 4.77
            }, {
                name: 'Opera',
                y: 0.91
            }, {
                name: 'Proprietary or Undetectable',
                y: 0.2
            }]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials