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

javascript - Remove Highstock series with specific ID - Stack Overflow

programmeradmin5浏览0评论

Hi I have just started working with Highstock's javascript charts and was trying to figure out a way of adding and removing chart items dynamically. I am already able to add the chart series dynamically and have given them unique names, as well as ID values but I'm not sure these are sticking. I was wondering whether or not there is a way to dynamically remove series without knowing their index in the series array?

Thank you in advance, Conor

Hi I have just started working with Highstock's javascript charts and was trying to figure out a way of adding and removing chart items dynamically. I am already able to add the chart series dynamically and have given them unique names, as well as ID values but I'm not sure these are sticking. I was wondering whether or not there is a way to dynamically remove series without knowing their index in the series array?

Thank you in advance, Conor

Share Improve this question asked Aug 26, 2011 at 12:21 Bob-obBob-ob 1,6184 gold badges20 silver badges35 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

I also had trouble getting this to work, but found out it is possible if you set the id manually before you add it to the chart, then use chart.get() to retrieve the series.

newSeries.id = myID;
chart.addSeries(newSeries);

You can then later call:

chart.get(myID).remove()

I'm using this code to dynamically remove all series from a chart:

for(i=0;i<chart.series.length;i++){
    chart.series[i].remove();
}

Worth noting that jQuerys $.each() didn't work, but the "for" loop did.

发布评论

评论列表(0)

  1. 暂无评论