Home » Javascript » Bokeh Taptool return selected index

Bokeh Taptool return selected index

Posted by: admin July 13, 2018 Leave a comment


I need to get the index of a selected data point in a Bokeh plot, which needs to be the input of another function in my web application.

I am using Bokeh’s Taptool CustomJS Callback. However, I could not find a way to get the actual index of the selected point besides ‘console.log’. Is there some way to return this index to outside the JavaScript?

Below is my code. I am new to Javascript and Bokeh. Thanks for any help in advance.

codes = """
    var index_selected = source.selected['1d']['indices'][0];

taptool.callback = CustomJS(args=dict(source=source),code = codes)