Simple Example of CustomJS to Change x_range / y_range?

I have a large number of plots in a figure. Based on user choices, I only have a subset of those plots visible at one time. I have been unable to discern the exactly correct syntax to change the x_range and y_range from inside the CustomJS javascript code. I wish to do this so that the range limits for the two axis make sense based on the visible plots, and are not just autoscaled to the maximum of the invisible plots.

While the functionality to autoscale based on only the visible plots would be nice, I suspect that I have to find and set my own limits each time the set of visible plots changes.

Would someone be able to provide a simple example of how to properly change those values on a figure from within CustomJS? My attempts to crib code from online seem to have no effect.

There is such functionality! Use DataRange1d(only_visible=True). It should work if you’re using the visible field to hide the renderers, just like an interactive legend does it.

Oh, my, dog! This is exactly what I needed!
Thank you x 10^100!