admin管理员组文章数量:1402837
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 badges2 Answers
Reset to default 6I 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.
本文标签: javascriptRemove Highstock series with specific IDStack Overflow
版权声明:本文标题:javascript - Remove Highstock series with specific ID - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744373504a2603144.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论