[英]Highcharts show/hide or toggle off all series at once
See my screenshot. 看我的截图。 How do I make a button/link which show/hide or toggle off all series at once?
如何制作一个同时显示/隐藏或关闭所有系列的按钮/链接?
So when I click the button it toggles off the 3 series (Mannen, Vrouwen, Totaal) at once. 因此,当我单击按钮时,它会立即关闭3个系列(Mannen,Vrouwen和Totaal)。
I think I have to do something in the Highcharts legendItemClick
function? 我想我必须在Highcharts
legendItemClick
函数中做些什么?
Update: 更新:
I added below code to my existing JS file, but I don't get any result? 我在现有的JS文件中添加了以下代码,但没有得到任何结果?
_showHideSeries: function (chart) {
$button = $('#button');
$button.click(function() {
var series = chart.series[0];
if (series.visible) {
$(chart.series).each(function(){
//this.hide();
this.setVisible(false, false);
});
chart.redraw();
$button.html('Show series');
} else {
$(chart.series).each(function(){
//this.show();
this.setVisible(true, false);
});
chart.redraw();
$button.html('Hide series');
}
});
},
You can loop through your series, and use the series.hide()
and `series.show() functions: 可以遍历的系列,并使用
series.hide()
和`series.show()函数:
$(document).on('click', '#hide-all', function() {
$.each(chart.series, function(i, ser) {
ser.hide();
});
});
Fiddle: 小提琴:
Reference: 参考:
Better use- (works much faster) 更好的使用-(工作更快)
$(chart.series).each(function(){
//this.hide();
this.setVisible(false, false);
});
chart.redraw();
Thanks to this genius- 多亏了这个天才
How can i hide all the Series in highcharts at a time 我如何一次将所有系列隐藏在高图中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.