I have a datatable which I am plotting via bokeh --serve. Upon clicking a value I want to return the row and column values to a ColumnDataSource (info_source), which I can then use in some following work through a python call from the same trigger. The issue is that the columns and rows are not populating the ColumnDataSource. I am not familiar with Javascript so having trouble debugging. Any pointers much appreciated.
source_1 = ColumnDataSource(df)
columns = ['x','y','z']
data_table_1 = DataTable(columns=columns, source=source_1)
data_table_1.height = 800
info_source = ColumnDataSource(dict(row = [], column = []))
code = """
var grid = document.children;
var row, column = '';
for (var i = 0,max = grid.length; i < max; i++){
if (grid[i].outerHTML.includes('active')){
row = i;
for (var j = 0, jmax = grid[i].children.length; j < jmax; j++)
if(grid[i].children[j].outerHTML.includes('active'))
{ column = j }
}
}
info_source.data = {row:[row],column:[column]};
"""
def py_callback(attr, old, new):
source_1.selected.update(indices = [])
def py2_callback(attr, old, new):
print(info_source.data)
plot_fwd = figure(x_axis_type='datetime',plot_width=400, plot_height=335)
source_1.selected.on_change('indices', py_callback)
callback = CustomJS(args = dict(source_1 = source_1, info_source=info_source), code = code)
source_1.selected.js_on_change('indices', callback)
source_1.selected.on_change('indices', py2_callback)`