[Solved] Keep zoom level on interval'd update

I have a plot of time vs. temperature that is updating on an interval. I’d like to preseve the zoom condition on update. Any easy way to do this? The default behavior seems to reset axes like so:

Thanks in advance.

4 Likes

I came up with a work around where I create a text input to control the xaxis: this works nicely for my current project but for future reference it’d be nice to understand the default reset behavior.

You can also get the zoom data from the relayoutData property of the
dcc.Graph object. With this, you can manually set the
layout.xaxis.range and layout.yaxis.range in your figure to be
whatever the new axis range is from the relayoutData. You could also add
a checkbox with a label like “Lock Camera” or “Lock View” that, if
selected, uses the range from the relayoutData, otherwise doesn’t set the
range manually. See this gallery app for an example:
https://plot.ly/dash/gallery/uber-rides/

1 Like

Thanks: that sounds quite useful. Much appreciated.

Just a quick update on this issue: we’ve incorporated your feedback and have created a first-class solution via a uirevsion property. See :mega: Preserving UI State, like Zoom, in dcc.Graph for an example and documentation.

Many thanks for sharing this example with us last year!

3 Likes