Brandon
Brandon

Reputation: 3146

Disabling a slice for a Highcharts pie chart when creating the chart

I have some pie charts on my site and they show quite a bit of data. I was wondering if there is a way to load the data, but initially hide any data that is less than some arbitrary value. When I say hide, I mean in the same way you can hide the certain data by clicking on the label in the legend. Then through the legend, have the user be able to show this data on the graph by clicking on the label in the legend. Is there a property or something I can use to accomplish this?

Upvotes: 0

Views: 1064

Answers (2)

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

You can define any variable as maxValue, then iterate on each point and call setVisible as false.

    var minValue = 10

    $.each(chart.series[0].data, function(i, point){
        if(point.y < minValue) {
            point.setVisible(false);
        }
    });

Example: http://jsfiddle.net/ct2jejgv/

Upvotes: 1

Raein Hashemi
Raein Hashemi

Reputation: 3384

Simply use this.chart.series[i].hide() / .show(). In your script, manually search for series less than your value and hide them like above. Its a simple foreach.

Upvotes: 0

Related Questions