Hi,
According to Python callback for HoverTool - Community Support - Bokeh Discourse it would be possible to get a python callback on the server when a HoverTool callback is triggered. This is achieved via a ColumnDataSource.
I tried to implement it but the server callback doesn’t get called. The HoverTool JS callback gets triggered and the datasource updated.
I was wondering if the datasource needs to be attached to a renderer.
Please find below a snipet of my code
hover_details_data_source = ColumnDataSource(
{
‘indices’: []
}
)
hover_details_data_source.on_change(‘data’, on_hover_callback)
code = “”"
console.log('indices: ’ + cb_data.index.indices)
const indices = cb_data.index.indices
if (indices.length){
data_source.data[‘indices’] = cb_data.index.indices
data_source.change.emit();
}
“”"
callback = CustomJS(
args={
‘data_source’: hover_details_data_source
},
code=code
)
hover = plot.select(“hover”)
hover.callback = callback
def on_hover_callback(attr, old, new):
print(‘Here’)