The following piece of python code that uses a ISO-formatted date string produces the graph below.
import plotly.express as px
import pandas as pd
bars = pd.DataFrame([{'Task': 'kitter_pick', 'Start': '2020-07-22T23:09:18.221013', 'Finish': '2020-07-22T23:09:25.221013', 'Counter': 2465}])
fig = px.timeline(bars, x_start="Start", x_end="Finish", y="Task",hover_name='Counter')
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up
fig.show()
result
The snippet is similar to https://plotly.com/python/time-series/ from the plotly documentation.
The timescale is completely incorrect due to the finish attribute being incorrectly interpreted by plotly.
When changing the timestrings slightly you obtain the correct result:
bars = pd.DataFrame([{'Task': 'kitter_pick', 'Start': '2020-07-22T23:09:18.221013', 'Finish': '2020-07-22T23:10:25.221013', 'Counter': 2465}])
Does anybody know why this happens and if there is a way around this?
I have also tried:
Both gave the same results
There is also a segment when the (end date is smaller than start + 1 second) and (end date is larger or equal than start - 0.001 seconds) where the chart does work as expected.
Got the same issue with timeline here. The problem is when the timedelta is less than 10 seconds, although when x_start = x_end it works fine.
Thanks for reporting this! It's indeed a bug in the underlying Javascript library, which we will fix: https://github.com/plotly/plotly.js/issues/5057
Should be fixed in the next version of plotly, within 10 days.
Fixed on master.
@nicolaskruchten I'm not sure if this issue is entirely solved, could you please see whether #2518 is related? Thank you.