user393267
user393267

Reputation:

Example to show/hide data with buttons/checkbox in Highcharts?

I was wondering if there is a way to show/hide series, based on either buttons or checkbox

I would like to have all my data in one big plot, but to not make it too cluttered, I would like to decide at runtime what data to display.

Is this possible? Is there an example that I can use as template? I have about 12 different data sets; which means that I need also to figure out how to load different data from different files, without write 12 different get data functions.

Upvotes: 1

Views: 1778

Answers (1)

SteveP
SteveP

Reputation: 19103

Highcharts has an API call for doing exactly what you want. The call you want is series.hide or series.show.

For example, the following code (from the highchars own examples) will toggle a series on an off:

    var series = chart.series[0];
    if (series.visible) {
        series.hide();
        $button.html('Show series');
    } else {
        series.show();
        $button.html('Hide series');
    } 

http://api.highcharts.com/highcharts#Series.show

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/members/series-hide/

Upvotes: 1

Related Questions