
I have a plot that is connected to a CDS. When I now update the data I would like the data to be shown as if it were set from the beginning (autoscaled). However it seems like that this is very much dependent on the previous zoom state.
No zoom before data update: works as desired.
Zoom before data update: zoom is kept despite data update
Additionally I noticed that autoscaling does not seem to trigger any RangeUpdate event. Is there any option to get a callback post autoscaling?
import numpy as np
from bokeh import events
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, Button, PanTool, BoxZoomTool, ResetTool
from bokeh.plotting import figure
from bokeh.layouts import row, column
doc = curdoc()
n_samples = 100
x = np.linspace(0, 1000, n_samples)
x2 = np.linspace(0, 1500, n_samples)
y = np.random.rand(n_samples)
source = ColumnDataSource({"x": x2, "y": y})
p1 = figure(width=400, height=400)
p1.line("x", "y", source=source)
def update_data():
source.data["x"] = x
button_update_data = Button()
button_update_data.on_click(update_data)
def range_updated(event):
print(f"range start {event.x0}, range end {event.x1}")
p1.on_event(events.RangesUpdate, range_updated)
doc.add_root(column(p1, button_update_data))


