Plotly.py: px.timeline chart incorrectly displays timeframes of 10 seconds and smaller.

Created on 22 Jul 2020  路  7Comments  路  Source: plotly/plotly.py

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}])

correct result

Does anybody know why this happens and if there is a way around this?

I have also tried:

  • datetime.datetime objects
  • np.datetime64 objects

Both gave the same results

stackoverflow link

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gv-collibris picture gv-collibris  路  4Comments

EmilienDupont picture EmilienDupont  路  4Comments

jjc12 picture jjc12  路  5Comments

astrojuanlu picture astrojuanlu  路  4Comments

tssweeney picture tssweeney  路  4Comments