【问题标题】:Hiding a Highcharts series without using the legend在不使用图例的情况下隐藏 Highcharts 系列
【发布时间】:2012-02-11 10:30:23
【问题描述】:

我需要能够从按钮而不是图例中隐藏 Highcharts 系列(原因是我需要从一个按钮切换多个组:Hiding _groups_ of series in Highcharts and jQuery: how to get acceptable performance? 并且由于该帖子中给出的原因,我不能使用$(chart.series).each() 使用 jQuery。

以下表达式均无效(我的图表对象名为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();

如果我知道它的索引,谁能告诉我如何隐藏图表系列?谢谢。

【问题讨论】:

    标签: javascript jquery highcharts


    【解决方案1】:

    这应该可行:

    chart.series[index].hide()

    Full example on jsfiddle

    UDP URL 来自 Simen Echholt 评论)

    【讨论】:

    • 您知道是否可以将系列从图例中完全删除?不只是让它变灰。
    • michaelAdam:你必须这样做chart.series[index].remove(true) (api.highcharts.com/highcharts#Series.remove)
    • 如果有像 remove() 这样的功能可以完全隐藏一个系列,然后再简单地把它放回去就好了。 [我有一个愚蠢而复杂的用户界面,它拥有我的经理可以想象的每一个功能,而对保持简单的考虑为零。]
    猜你喜欢
    • 2012-03-17
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多