I want to select a region in a multi_line chart and use js code to calculate some statistics of the selected region.
The code below demonstrates what I mean. The issue is that the selection does not call the JS script at all.
What is the suggested and propper way to do it?
from bokeh.models import BoxSelectTool, ColumnDataSource, CustomJS from bokeh.plotting import figure, show x = [[1,2,3,4,5], [1,2,3,4,5]] y = [[8,6,5,2,3], [3,2,5,6,8]] s1 = ColumnDataSource(data=dict(x0=x, y0=y)) p1 = figure(width=400, height=400, tools="", title="Select Here") p1.add_tools(BoxSelectTool()) p1.multi_line('x0', 'y0', source=s1, alpha=0.6) s1.selected.js_on_change('indices', CustomJS(code=""" console.log('selection of a region'); // now calculate some statistics """) ) show(p1)
For example: in the attached selection I would like to have
s1.selected.indices =