Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

How to reset zoom on a plot

I have a page containing several small charts. Selecting one of those causes the same data to be plotted in a larger chart. “Closing” that (it’s a fullscreen div that gets hidden) allows another small chart to be selected, reusing the original large chart. I do have a call to Plotly.purge(element), but any zoom applied to the large chart persists across uses. Is it possible to ask a plot to zoom to the extents of it’s data (and continue to allow user zooming), or should I just remove and re-create the DOM element to get a fresh start?

Setting the layout.xaxis.range and layout.yaxis.range fields should do the trick here.

That worked great, thanks.

1 Like