I have a simple vbar plot and I am using the TapTool to trigger a callback when a specific bar is selected. When selecting a bar, it is highlighted, the others are faded, and the callback is triggered.
But I cant figure out how to get a callback to trigger when I un-select the bar. If i click in the white space of the graph, the bars all return to normal coloring, but i cant trigger a callback.
I tried using the js_on_event(tap, callback) but, as expected, this triggers anytime there is a tap anywhere on the plot.
+569+
How can I get the a callback to trigger only on the un-select (when i tap in the whitespace)?
import bokeh.plotting
import bokeh.io
import bokeh.layouts
from bokeh.models import CustomJS,TapTool
from bokeh.models import ColumnDataSource
import pandas as pd
bokeh.io.output_file("bar.html")
fruit = ['apple', 'orange', 'pear']
data = pd.DataFrame({'x': fruit, 'y': [3, 4, 6]})
s1 = ColumnDataSource(data)
p3 = bokeh.plotting.figure(x_range=fruit)
p3.vbar(x='x', top='y', width=.9, source=s1)
tap = TapTool(callback=CustomJS(args=dict(s1=s1), code=""" console.log("bar selected");"""))
p3.add_tools(tap)
layout = bokeh.layouts.layout(p3)
# This is triggered on clicks in both the whitespace and on a bar, which me
# p3.js_on_event('tap', CustomJS(args=dict(s1=s1), code=""" console.log("no bars selected");"""))
bokeh.io.show(layout)
Thanks!

