Open divyankm opened 2 years ago
Comments from Stack overflow user-
Yes it seems like a bug with the range selector (type='date')
. It occurs when setting the scatter plot mode to 'markers' or 'lines+markers'
: in fact, using markers leads to the addition of an extra range added to the xaxis, extending the default date range from the input data.
So when you click on 2w
, the slider goes from that out-of-range date (in the future) back to 2w before that date, the same happens with the other ranges actually, not only 1m, but it is less noticeable for bigger ones.
You could set a fixed range to circumvent the problem using rangeslider_range and range :
fig.update_xaxes(
rangeslider_visible=True,
rangebreaks=[dict(bounds=["sat", "mon"])],
range=[df.index[0], df.index[-1]],
rangeslider_range=[df.index[0], df.index[-1]]
)
...until you click on all
. The problem is that the range selector button step='all' will always reset the layout to use the extended range.
This does not happen when you set the scatter mode to just mode=lines
. In this case the default/'all' slider range fits the data.
So I guess the quick fix is to remove markers, the long one is to use Dash callbacks to have a full control of what the buttons do.
Ref link- plotly-weekly-monthly-range-selector-buttons-not-working-on-time-series-data
I'm having the exact same issue, which is very well explained in the post above, this is a pretty annoying bug for time series/financial data.
I've avoided using scatter for the past 2 years with plotly for this reason alone. What would need to be done to fix this? Isn't this a plotly.js issue?
In my case all selectors have always been broken: The empty space added is troublesome: and it's particularly problematic for 1m:
Hi,
I am having last 1 year time series financial data. I removed weekends as no data is present.
I created plotly viz,
2w
,1m
range selector buttons are not showing correct time range. WhileYTD
,6m
,all
showing correct data.2w
button showing 2 week forward days but there is no data, want to see last two week and 1m data.Reproducable Code-
Pls let me know , if there is any bug in plotly range selector or I am doing something wrong in
xaxis=dict(rangeselector=dict(buttons=list([xaxis=dict(rangeselector=dict(buttons=list([
code. I trieddict(count=14,label="2w",step="day",stepmode="backward")
but still same issue.Snaps- When I click on
2w
but it show future dates, where no data is present in dataframe.1m button snap-