score:1

Pretty old thread, but info still usefull.

As @Alvara pointed out, with hundreds of series, using .hide() or .show() is quite slow (browser freeze few seconds).

Using setVisible(false, false) and setVisible(true, false) is way faster :

legendItemClick: function (event) {
  if (!this.visible) return true;

  const series = this.chart.series;
  const serieLen = series.length;

  if (series.filter(s => s.visible).length === 1) {
    for (let i = 0; i < serieLen; i += 1) {
      series[i].setVisible(true, false);
    }
  } else {
    for (let i = 0; i < serieLen; i += 1) {
      series[i].setVisible(false, false);
    }
    series[this.index].setVisible(true, false);
  }
  return false;
};

Even with big series, it works instantaneously.

Using .show().hide() on +50 series already take more than 2 sec to toggle visible series (https://jsfiddle.net/rockshappy/nL5j2rLa/5/)

Here using setVisible is instantaneous (https://jsfiddle.net/rockshappy/nL5j2rLa/2/)

score:9

I don't believe that highcharts has a hideAll() or similar function, but you could try something like this:

//assuming chart is your chart
series = chart.series;
for(var i = 0; i < series.length; i++) {
    if(!series[i].selected) {
        series[i].hide();    //Hide the series
    }
}

Then you would just need to call that code whenever you select a series. You could probably do this by performing some sort of check using chart events


Related Query

More Query from same tag