Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide/show all series in Highcharts?

Tags:

highcharts

I have like 50 different series, so by default, I have them hidden, so the user simply clicks on the ones he wants to see.

Sometimes, one wants to show all, or hide all, quickly. I cannot figure out how to toggle all on/off. Is this possible at all? I assume so, but cannot figure out a way to do it.

like image 245
user2633291 Avatar asked Sep 15 '13 22:09

user2633291


People also ask

How to hide series in highcharts?

get(1). hide(); $(chart. series[1]).

How to hide series name in highcharts?

If you don't want to show the series names in the legend you can disable them by setting showInLegend:false .


2 Answers

Hide each series using series.setVisible(false, false), reference. - After all series will be hidden call chart.redraw() to redraw chart only once.

like image 150
Paweł Fus Avatar answered Oct 13 '22 05:10

Paweł Fus


this solution is based on http://jsfiddle.net/pGuEv/

  var chart = $('#chart-container').highcharts();
  var $hide_show_all_button = $('#hide_show_all_series_button');

  $hide_show_all_button.click(function() {
    var series = chart.series[0];
    if (series.visible) {
      $(chart.series).each(function(){
        this.setVisible(false, false);
      });
      chart.redraw();
      $hide_show_all_button.html('show all');
    } else {
      $(chart.series).each(function(){
        this.setVisible(true, false);
      });
      chart.redraw();
      $hide_show_all_button.html('hide all');
    }
  });
like image 33
s2t2 Avatar answered Oct 13 '22 06:10

s2t2