I am trying to get the data for lasso selected points on a Bokeh scatter chart using a callback.
I am working off an example shown here: Bokeh Server callback from tools
from bokeh.plotting import figure, curdoc, show, output_file
from bokeh.models import ColumnDataSource
from bokeh.layouts import column
from bokeh.io import curdoc
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=list('XY'))
source=ColumnDataSource(df)
p = figure(title="Some Figure", tools=["lasso_select"])
pglyph = p.circle(x='X', y='Y', source=source)
def callback(attr, old, new):
# The index of the selected glyph is : new['1d']['indices'][0]
patch_name = source.data['X'][new['1d']['indices'][0]]
print("LassoTool callback executed on Patch {}".format(patch_name))
pglyph.data_source.on_change('selected',callback)
curdoc().add_root(column(p))
#bokeh serve --show TestApp.py
What do I need to change to make the print function work when running this script using Bokeh Server? This will help me understand how I would be able to access the data of the selected features to use as a source for another chart.