We build all of our charts dynamically based on user choices. I’m trying to allow users to change the data loaded into the chart and rebuild the chart traces (the data), legend, and overall axis ranges, but leave their pan position or zoom level unchanged. (E.g. if they’re zoomed into an area, leave it zoomed into that area). I’ve tried a few approaches:
- Rebuild the trace configs, and just call deleteTraces() and then addTraces() with the new traces
- Using Plotly.update(). However, I seem to get different results depending on how I use it (passing in brand new trace and layout objects, vs. using the existing trace and layout objects but overwriting their properties). Sometimes it’ll rescale the charts anyway, sometimes it’ll keep the zoom level if the ranges are bigger or smaller than they originally were, etc.
If there isn’t an obvious way to do this “automatically”, then is there a way to interrogate the chart to get the pan position (current chart center?) and zoom level, and manually re-apply it after the update?