I have sensor readings where I plot the reading on y and datetime on x. When I use arange(len(readings)) Scattergl works. When I use the datetime, I get runtime disconnect. I am running within Google colab.
import numpy as np
x_axis = np.arange(df['Pa'].count())
# Create figure
fig = go.Figure()
fig.add_trace(
go.Scattergl(
x = x_axis,
# x = df['Pa'].index,
y = df['Pa']
)
)
fig.update_layout(title_text='title',
xaxis_rangeslider_visible=True)
fig.show()
The above works because x is 0 to the number-1 of readings. The above does not work when x is the datetime.
Note: Readings are one second apart:
For me it works with even more data (len(df) = 777600):
import pandas as pd
import numpy as np
from datetime import datetime
import plotly.graph_objects as go
dt = []
for k in range(1, 10):
dt += [datetime(2020, 1, k, h, m, s) for h in range(0, 24) for m in range(0,60) for s in range(0,60)]
d ={'date': dt,
'y': np.random.randint(2,15, len(dt))}
df = pd.DataFrame(d, index=d['date'])
fig = go.Figure()
fig.add_trace(
go.Scattergl(
x = df.index,
y = df['y']
)
)
fig.update_layout(title_text='title',
xaxis_rangeslider_visible=True)
fig.show("browser")
Plotly.js can handle fractional seconds and some timezone info (-08:00, also -0800 and Z) though currently it just ignores this https://codepen.io/alexcjohnson/pen/abzPgJK?editors=0010
So these are all valid once they make it to javascript:
The runtime disconnect makes me think there’s another issue at play, and these values aren’t even making it to the graph. I’m not sure what the problem is though, AFAICT our JSON serializer has no trouble with timezones:
Huh ok, thanks for checking. So the serializer works, and the resulting string works on the javascript side… I’m puzzled where the problem could be.