exclude data point from legend on pie chart - Javascript highcharts

Javascript examples for highcharts:Chart Legend

Description

exclude data point from legend on 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"> 
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/*from w  ww .jav a 2  s .  com*/
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'pie'
        },
        plotOptions: {
            pie: {
                point: {
                    events: {
                        legendItemClick: function (event) {
                            console.log(this);
                            var thisSeriesId = this.id;
                            var thisSeriesVisibility = this.visible ? true : false;
                            $(chart.series).each(function (i, e) {
                                $(e.data).each(function(j, k){
                                    if (thisSeriesId === k.id) {
                                        thisSeriesVisibility ? k.setVisible(false) : k.setVisible(true);
                                    }
                                });
                            });
                            event.preventDefault();
                        }
                    }
                }
            }
        },
        series: [{
            showInLegend: false,
            ignoreHiddenPoint: true,
            data: [
                ['Firefox', 44.2], {
                    name: 'IE6',
                    id: 'rel1',
                    y: 20,
                    color: 'blue'
                }, ['Chrome', 3.1],
                ['Other', 5.4]
            ]
        }, {
            dataLabels: {
                enabled: false
            },
            showInLegend: true,
            data: [{
                name: 'IE6',
                id: 'rel1',
                y: 0,
                color: 'blue',
            }]
        }]
    });
});

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

Related Tutorials