Skip to content

Bar chart with timeseries index not displaying depending on proximity of the times #2987

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

Open
erichards97 opened this issue Dec 22, 2020 · 0 comments
Labels
bug something broken P3 backlog

Comments

@erichards97
Copy link

Found an issue causing a bar chart to display nothing when displaying timeseries data. It seems to be caused by having stacked data at two points which are very close in time (e.g. 12:00:00 and 12:00:01) and then one point much further away (e.g. 17:00:00).

import pandas as pd
import plotly.express as px

times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:01']  
#times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00'] <-- works
vals = [10, 50, 20, 350, 250]

# Uncomment to cause bar chart to display no data
# times.append('2020-12-18 13:00:00')
# vals.append(1)
  
df = pd.DataFrame(list(zip(times, vals)), 
               columns =['DT', 'Val']) 

df['DT'] = pd.to_datetime(df['DT'])

df = df.set_index('DT')
fig = px.bar(df, x=df.index, y=df['Val'])

fig.show()
  • The code unchanged displays the figure fine
    1
  • If you uncomment the two append lines, adding in a data point which is further away, then the figure is empty
    2
  • If you uncomment the two append lines and changes the initial times list so that they are all :00, the figure displays fine
    3

Therefore it seems to be caused by having points at 02:15:00 / 02:15:01 and then a point much later at 13:00:00

Thanks

@gvwilson gvwilson self-assigned this Jun 24, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 12, 2024
@gvwilson gvwilson changed the title Bar chart with timeseries index not displaying depending on proximity of the times (easily reproducible) Bar chart with timeseries index not displaying depending on proximity of the times Aug 12, 2024
@gvwilson gvwilson added the bug something broken label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants