开发者

Highcharts JS setData in spline

开发者 https://www.devze.com 2023-02-07 06:44 出处:网络
I have a chart I want to update when a user updates something in his/her profile. The data structure is like this:

I have a chart I want to update when a user updates something in his/her profile. The data structure is like this:

var chartData = "[date1,weight1],[date2,weight2],[date3,weight3]";

I create the string in JS before sending the string to setData. H开发者_运维百科owever I cant get the update to work:

chart.series[0].setData([chartData]);
chart.redraw();

What I want to do is update the axis with the dates and plot the weight for the user. I am sure I am doing it wrong, but I cant figure out, what I am doing wrong - I am sure you know the feeling :)


Sample code:

var chartData = [];

// push two items to chart
chartData.push({ name: "my item #1 title", y : 100 });
chartData.push({ name: "my item #2 title", y : 200 });

// update chart data
chart.series[0].setData(chartData);


this should work

chart.series[0].setData([chartData], true);
0

精彩评论

暂无评论...
验证码 换一张
取 消