Is it possible to do simple dynamic selection of data with a slider in Bokeh without a custom Python callback? Here is what I can do using a callback, but it would need a Bokeh server to work in exported html:
import numpy as np
import pandas as pd
import ipywidgets as widgets
from bokeh.io import show, push_notebook
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource
x = np.arange(0, 10, 0.1)
dfs = []
ts = range(100)
for t in ts:
y = x**(t/50.)
dfs.append(pd.DataFrame({"x": x, "y": y, "t": t}))
df = pd.concat(dfs)
cds = ColumnDataSource(df)
p = figure(x_range=(0,10), y_range=(0,100))
p.scatter(x='x', y='y', source=cds)
handle = show(p, notebook_handle=True)
def update(t):
cds.data = df[df.t == t]
push_notebook(handle=handle)
slider = widgets.SelectionSlider(value=0, options=ts)
io = widgets.interactive_output(update, {"t": slider})
display(slider, io)
However it really feels like a custom callback should not be necessary for this, and it is quite a pain in my larger application. Is there not some clever way it can be done purely with Bokeh-native objects, like a CDSView or filter or something? I'm sure some custom javascript can do it too, but again I'd rather not if possible.
