Scatterplot Using Dates on the X-Axis line messed up

Hi,

I have a plot as shown in Using Dates on the X-Axis.
My dates are not inserted in a specific order, but I’d like to have a chronological line through all date points.
Instead I get a line that follows the order of the dates in the trace.

Is there an easy way to handle this or do I have to sort x and y traces by the dates in x before plotting?

Thanks in advance,
Rena

Plotly doesn’t expose an attribute that does that. You can use the native JS .sort array function to do so.

Something like:

{
  x: dates.sort(function (a, b) {  new Date(a).getTime() - new Date(b).getTime() })
}

should do the trick.