Hide / show all episodes in Highcharts?

I have 50 different episodes, so by default I hide them, so the user just clicks on the ones he wants to see.

Sometimes, everyone wants to show everything or hide everything, quickly. I can't figure out how to toggle everything on / off. Is it even possible? I think so, but I can’t figure out how to do it.

+6
source share
2 answers

Hide each series using series.setVisible(false, false) link . - After all series are hidden, call chart.redraw() to redraw the chart only once.

+7
source

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'); } }); 
+2
source

Source: https://habr.com/ru/post/953884/


All Articles