Hi,
I’m trying to do some simple selection callback with bokeh 12.15. The following example works in bokeh server (replacing of course ‘output_notebook’ and ‘show’ by ‘curdoc().add_root()’ but it does not seem to work in latest jupyter notebook 5.4.1 (nor jupyterlab)
from bokeh.plotting import figure, output_file
import numpy as np
from bokeh.models import ColumnDataSource,BoxSelectTool,LassoSelectTool
#output_file(“toolbar.html”)
from bokeh.io import output_notebook,show
output_notebook()
x = np.arange(1000)
y = np.random.normal(loc=1,scale=2,size=1000)
source = ColumnDataSource(data=dict({‘x’:x,‘y’:y}))
tools = “pan,box_zoom,lasso_select,reset”
p = figure(plot_width=400, plot_height=400,
title=None, toolbar_location=“below”,
toolbar_sticky=False,tools=tools)
c=p.circle(x=‘x’,y=‘y’,source=source)
def update(attr,old,new):
print(new.indices)
print(type(c.data_source.selected))
c.data_source.on_change(‘selected’,update)
show(p)
print(type(c.data_source.selected))
``
On the plot I see the change of style of selected points but the selected object of the source seems to never be instanciated.
Am I missing something or is this a bug (I saw that bokeh 12.15 introduced a new selection model…) ?
Thanks for your help.
Raphael