hide a pie slice programatically - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

hide a pie slice programatically

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 () {//from   ww w . j  a  v a  2  s  . c o  m
    $('#container').highcharts({
        chart: {
            type: 'pie'
        },
        legend: {
            align: 'right'
        },
        plotOptions: {
            pie: {
                showInLegend: true,
                allowPointSelect: true,
                dataLabels: {
                    enabled: false
                }
            }
        },
        series: [{
            data: [{
                name: "A",
                y: 20
            }, {
                name: "B",
                y: 30
            }, {
                name: "C",
                y: 40
            }]
        }]
    });
    // button handler
    var chart = $('#container').highcharts(),
        sliced = false,
        i = 0;
    $('#button').click(function () {
    if(sliced)
        chart.series[0].data[0].setVisible(true);
    else
chart.series[0].data[0].setVisible(false);
        sliced=!sliced;
    });
});

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

Related Tutorials