Javascript 在不使用图例的情况下隐藏 Highcharts 系列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8880748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hiding a Highcharts series without using the legend
提问by bokov
I need to be able to hide a Highcharts series from a button rather than the legend (the reason is that I need to toggle multiple groups from one button: Hiding _groups_ of series in Highcharts and jQuery: how to get acceptable performance?and for the reasons given in that post, I cannot use $(chart.series).each()
with jQuery.
我需要能够从按钮而不是图例中隐藏 Highcharts 系列(原因是我需要从一个按钮切换多个组:Hiding _groups_ of series in Highcharts 和 jQuery:如何获得可接受的性能?以及在那篇文章中给出的原因,我不能$(chart.series).each()
与 jQuery 一起使用。
None of the following expressions have any effect (my chart object is named chart
):
以下表达式均无效(我的图表对象名为chart
):
Chart.series.get(1).hide();
chart.series.get(1).hide();
$(chart.series[1]).hide();
$(chart.series["1"]).hide();
$(chart.series[1]).hide();
$(chart.series)["1"].hide();
$(chart.series)[1].hide();
Can someone please tell me how I can make a chart series hide if I know its index? Thanks.
如果我知道它的索引,有人可以告诉我如何隐藏图表系列吗?谢谢。
回答by eolsson
This should work:
这应该有效:
chart.series[index].hide()
chart.series[index].hide()
(UDPURL from Simen Echholt comment)
(来自 Simen Echholt 评论的UDPURL)