When the page with our charts loads, we populate it with legacy data (x is a timestamp, y is a value) we get from a database. I have set the json-encoded array we generate from our PHP script which fetches this info as the default data source for our graph, and I have our update function push to this data variable. The chart IS updating, however, it creates a nasty new line under the rest of the data.
It doesn’t look like there is anything inconsistent, what appears to be happening is that when I add a new data point it renders from the very first point in the data set to the new one I pushed, which seems very odd.
This reply was modified 3 months, 2 weeks ago by James.
Sorry, we are unable to reproduce the issue. Kindly check this jsfiddle.
It seems like the issue happens when you try to update the chart and the dataPoints are not sorted. Can you kindly update the jsfiddle, reproducing the issue, so that we can look into it and help you better?
It will try, however the link I used to our JSON API is not public, it is only available internally, so I’ll basically have to create a fake one. Will update when I can, though I can assure you the data is sorting 100% correctly after triple checking it, and the data appears correctly after it begins to update, in the correct place, etc. The issue is that the first time we add a new data point, instead of adding to end of the current line, it seems to only recognize the first point of the initial data points and draws directly from that starting point to the new data point.
Update: Switching from using .push to .unshift in my update code seems to have solved the problem. Even though in the source, both .push and .unshift were adding the items in the proper order, it seems the display wasn’t able to understand that. :)