Skip to content

px.timeline chart incorrectly displays timeframes of 10 seconds and smaller. #2658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Denpeer opened this issue Jul 22, 2020 · 8 comments
Closed

Comments

@Denpeer
Copy link

Denpeer commented Jul 22, 2020

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

@Talon24
Copy link

Talon24 commented Jul 22, 2020

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.

@arielcedola
Copy link

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.

@nicolaskruchten
Copy link
Contributor

Thanks for reporting this! It's indeed a bug in the underlying Javascript library, which we will fix: plotly/plotly.js#5057

@nicolaskruchten
Copy link
Contributor

Should be fixed in the next version of plotly, within 10 days.

@nicolaskruchten
Copy link
Contributor

Fixed on master.

@dpasqualin
Copy link

@nicolaskruchten I'm not sure if this issue is entirely solved, could you please see whether #2518 is related? Thank you.

@saksham7778
Copy link

@nicolaskruchten Can we use start and end to view information in nanoseconds ( or by passing an integer array ) ? Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants