Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a highcharts pie slice programatically

I have a highcharts pie chart which allows you to remove slices by clicking on the legend.

http://jsfiddle.net/f3Lx6cxk/

I want to programatically hide slices aftr the chart has been rendered. In my jsfiddle, the button calls

chart.series[0].data[i].select();

which has the effect of sliding the slice out. I want a similar call to remove the slice altogether, but leave it greyed out in the legend (so point.remove is no good). The effect should be the same as clicking on the legend item.

like image 236
SteveP Avatar asked Dec 17 '14 11:12

SteveP


1 Answers

You can use setVisible function:

    $('#button').click(function () {
    if(sliced)
        chart.series[0].data[0].setVisible(true);
    else
chart.series[0].data[0].setVisible(false);

        sliced=!sliced;
    });

http://jsfiddle.net/f3Lx6cxk/1/

like image 85
Sebastian Bochan Avatar answered Oct 05 '22 04:10

Sebastian Bochan