You must be logged in to post your query.
Home › Forums › Chart Support › Pushing a datapoint in front
Tagged: datapoints push unshift
Hello and thank you for this wonderful tool.
I am trying to add a datapoint on the go to the graph and using chart.options.data[0].dataPoints.push({ y: 25 - Math.random() * 10}); works fine when we are adding a new point to the end of the graph.
chart.options.data[0].dataPoints.push({ y: 25 - Math.random() * 10});
However should I wish to add a a new point at the beginning of the graph (on x-axis) using the unshift method instead of push the y axis gets draw accordingly but the x axis stays the same and doesn’t take the gap like pushing does.
Any help wpuld be great.
Hi,
In this case you have to assign x value also or you need to increase auto assigned x value for each dataPoints. Please check this example.
Brilliant thank you
Hello again,
I have noticed that when assigning a negative value to x I am getting unwanted values on the x axis (on certain graph widths) however this isn’t the issues with positive number assigned to x values.
This link is a forked version of yours with two graphs, one for negative x values and one for positive x values: http://jsfiddle.net/Kustuldi/cfbhkz8z/
Any help would be great, Regards Chris
Thanks, for reporting the issue. It’s a bug, and we have just fixed the same. Here is an internal build for you.
Fixed it thank you
You must be logged in to reply to this topic. Login/Register