How do I dynamically change a data point in Highcharts using JavaScript

半腔热情 提交于 2020-01-12 07:09:13

问题


I'm trying to change a point in an existing series. From looking at the API, I've been trying the following:

chart.series[0].data[0].y = 43;
chart.redraw();

I'm sure I'm missing something simple but I can't figure it out. Thanks for your help.


回答1:


You can't just set the value. chart.series[0].data[0] returns a point object, which you can then use it's 'update' method to change it's values.

chart.series[0].data[0].update(y += 10); 

You can see an example here: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/members/point-update-column/




回答2:


Well it works properly for both coordinates: http://jsfiddle.net/PsBh7/

 chart.series[0].data[0].update({
                x:20
            }); 


来源:https://stackoverflow.com/questions/15161869/how-do-i-dynamically-change-a-data-point-in-highcharts-using-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!