predict-idlab / plotly-resampler

Visualize large time series data with plotly.py
https://predict-idlab.github.io/plotly-resampler/latest
MIT License
990 stars 67 forks source link

[BUG] Figures updated with layout.uirevision do not resample #252

Open AndrewHarrisNL opened 11 months ago

AndrewHarrisNL commented 11 months ago

Describe the bug :crayon: Updating a plot with the layout.uirevision property set resamples to the entire dataset, and not the zoomed view.

Reproducing the bug :mag: This can be reproduced in 02_minimal_cache.py by adding the following line to plot_graph just before the figure is returned: fig.layout.uirevision = 'test'

Here's the full code with edits: https://pastebin.com/5nb6UXJA

Zooming into a specific section of the plot resamples as expected:

image

But after pressing the 'plot chart' button again, the plot is not resampled properly:

image

Expected behavior :wrench: The resampling should take zoom preserved by uirevision into account, so the resampling adjusts after an update.

Environment information: (please complete the following information)

Additional context It seems that there is no relayout event triggered after a plot update with uirevision, so construct_update_data never executes. I tried changing the update_fig callback to address this (changing the store state -> input), but the relayoutData property is reset after an update so this doesn't work either.

As well, the newest version of dash_extensions has changed ServersideOutput -> Serverside, and it is now a wrapper around the returned value instead of in the callback definition. I have updated this for my example, I can also make a PR if that would be helpful 😄