Black Lives Matter. Please consider donating to Black Girls Code today.

Time series plot working weird with unsorted data?

I have a web app that graphs out some measurements from a logfile on my computer. Until recently, it’s worked fine. However, I just noticed that whenever the logfile accidentally appends a measurement in the wrong order, Plotly graphs it wrong. In other words, the app has worked up until now because the time measurements had always been appended to the logfile in the right order, but in the rare case that they’re not, Plotly draws the splines in the order that the points appear on the list rather than through chronological order. Here’s an image of my problem: http://imgur.com/a/AZtM6

I know that one option is to simply sort all of my y-axis arrays with respect to a sorted x-axis time array. However, my arrays are rather large so that might take too much time. I’m wondering if Plotly has a more convenient, built-in way to fix this issue.

That’s probably because plotly.js thinks your data is in-fact categories instead of dates (categories are plotted in order of the input array).

To ensure that your dates are plotted as dates, you convert your data to valid date formats as described on http://help.plot.ly/date-format-and-time-series/