Autoscale Y axis on Double Click for data in-view

Hey all!

So I’ve been doing quite a bit of work with multiple-axes charts, but what I find to be the most annoying component of my implementation is that I’m unaware of a good way to rescale the axes based on the current data within the zoom range. When you double click on a given axis, the axis is rescaled based on the entire range of data, so on shorter time horizons, I find that my charts end up just being horizontal lines, which is not especially useful. I figure that this is probably a common enough problem that I would toss it out to people to see if you have any solutions for this issue?

Thanks!

1 Like

You could make a button, or whatever other input, that sends to a callback that updates the layout of the figure.
something like this:

my_fig.update_layout(
yaxis={‘range’:[y_view_low, y_view_high}}

You could write a custom function to automatically set the values for the 2 y_view paramaters. I’ve done this for automically scaling candlesticks charts based on the rowSelected input from an AGGrid. Look through the documentation to see what other parameters you can tweak for fig.update_layout.

Cheers!

Use scaleanchor.

JS: Layout.xaxis in JavaScript

Python: Layout.xaxis in Python

Hm, this might be the solution, but do you mind adding an MWE for how this might work in Dash with multiple axes? If not, I can play around with it and post my findings after some trial-and-error. My main concern is that it might be a bit more rigid than the desired link (i.e. would I need to return a Patch to the graph to remove the scaleanchor if the user wanted a floating ratio?).