Dash Plot strangely creates multiple traces

I am returning the chart from a callback like so:

dcc.Graph(id=“chart”,
figure={“data”: plots, “layout”: layout},
style={‘height’: 800, ‘width’: 800}
)

where plots are a list of plots as defined below:
plot = go.Scatter(x=x,
y=y,
mode=“lines”,
name=legend)

x is a list of 870 string formated dates, and y is a list of 870 numbers.

What I received on the front end looks like this:

The weird thing is that when I do a stack plot or bar plot, the plot looks fine:

It’s only line plot that is behaving strangely.

How should I correct this?

I have figured this out myself. I will need to make sure that the date index of the dataframe is sorted, otherwise the chart got messed up as it is shown.

1 Like