最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - highcharts link series such that turn one off turns off the other - Stack Overflow

programmeradmin3浏览0评论

I would like to link a pair of series in highcharts so that clicking either one in the legend turns both in the pair on/off.

For example, in this fiddle, if I click 1A in the legend I would like it to also turn off 2A but leave 1B and 2B unaffected. Clicking 2A should also turn off 1A, i.e. the link should work both ways.

Is there a way to achieve this?

I would like to link a pair of series in highcharts so that clicking either one in the legend turns both in the pair on/off.

For example, in this fiddle, if I click 1A in the legend I would like it to also turn off 2A but leave 1B and 2B unaffected. Clicking 2A should also turn off 1A, i.e. the link should work both ways.

Is there a way to achieve this?

Share Improve this question asked Jul 9, 2013 at 9:41 harrygharryg 24.1k47 gold badges134 silver badges208 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

You can also use linkedTo options from Highcharts, see: http://jsfiddle/GCqsf/4/

There is only one limit - linked series isn't displayed in legend, so probably it may not fit the best your example. Since Highcharts 3.0.7 you can set series.showInLegend = true to display linked series in legend.

You'll have to handle the legendItemClick event and specifically hide (and show) the "sister" series.

I have a running example in this jsFiddle.

Note that I'm using the links variable as an easy way to get the "sister" series for a given series.

Also note that I've added an id to each series so that chart.get() returns the series when given its id.

发布评论

评论列表(0)

  1. 暂无评论