It's possible (nay, likely) that I'm misunderstanding something but the docs indicate that Numpy arrays containing timestamps should be allowed. Yet, I'm currently having to cast this into a Pandas Series for it to work:
# plotly date axis bug?importdashimportdash_core_componentsasdccimportdash_html_componentsashtmlimportplotly.graph_objectsasgoimportnumpyasnpimportpandasaspdapp=dash.Dash(__name__)
timestamps=np.array(
[
'2017-05-24T23:00:21',
'2017-05-24T23:00:23',
'2017-05-24T23:00:25',
'2017-05-24T23:00:27',
'2017-05-24T23:00:29'
],
dtype='datetime64[ns]'
)
fake_data=np.arange(len(timestamps))
fig_working=go.Figure().add_scatter(
x=pd.Series(timestamps),
y=fake_data
).update_layout(xaxis_type='date')
fig_working_not_so_much=go.Figure().add_scatter(
x=timestamps,
y=fake_data
).update_layout(xaxis_type='date')
app.layout=html.Div(
[
html.H1("Working with a pandas.Series:"),
dcc.Graph(figure=fig_working),
html.H1("Same data in a numpy.array:"),
dcc.Graph(figure=fig_working_not_so_much),
html.H1("😿")
]
)
if__name__=='__main__':
app.run_server(debug=True)This yields:

It's possible (nay, likely) that I'm misunderstanding something but the docs indicate that Numpy arrays containing timestamps should be allowed. Yet, I'm currently having to cast this into a Pandas Series for it to work:
This yields: