Black Lives Matter. Please consider donating to Black Girls Code today.

How do I get x-values from slider?

I’m trying to rescale my y-axis in a candlestick graph automatically through using the maximum and minimum value between the selected range in my x-axis. To do this I need to get the range of x-values that I’ve selected with the slider. How do I obtain this?

Theoretically, to get the x-axis range value, you can access it directly from the layout if it is already set before.

If you have a Figure object:

range = fig.layout.xaxis.range   # returns a tuple (min, max)

But when used with the candlestick example from the docs, code above return None because we haven’t set the range before.

I think what you’re trying to achive is similar to this other post and currently it is not supported.