Hello,
I am struggling to add a js_on_event to a figure tool.
In the simple example below, the message “test” does not shows up in the console.
None of the 3 methods work, I don’t know how to access the button from the toolbar:
from bokeh.plotting import figure, show
from bokeh.models.tools import ResetTool
p = figure(width=400, height=400)
# method 1
p.toolbar.js_on_event(
"button_click",
CustomJS(
code="""
console.log('test');
"""
)
)
# method 2
reset_tool = [v for v in p.toolbar.tools if isinstance(v, ResetTool)][0]
reset_tool.js_on_event(
"button_click",
CustomJS(
code="""
console.log('test');
"""
)
)
# method 3
reset_tool = [v for v in p.tools if isinstance(v, ResetTool)][0]
reset_tool.js_on_event(
"button_click",
CustomJS(
code="""
console.log('test');
"""
)
)
# add a scatter circle renderer with a size, color, and alpha
p.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
# show the results
show(p)
Anyone has an idea?
Thanks