I have two separate problems with the taptool, I illustrate them in the code below
1- About issue #3804 , is it still not possible to have several taptools active at the same time?
2 - The CustomJS works fine with show(); but not with a bokeh server. In a bokeh server the line can be clicked twice before the callback stops working without giving any errors.
from bokeh.io import curdoc,show
from bokeh.plotting import figure
from bokeh.models import TapTool, HoverTool, ColumnDataSource, CustomJS
s = ColumnDataSource(data={‘x’:range(10),‘y’:range(10)})
s2 = ColumnDataSource(data={‘x’:range(10),‘y’:range(10)[::-1]})
fig = figure(tools=‘box_zoom’)
a = fig.line(x=‘x’,y=‘y’,color=‘lightgrey’,line_alpha=0.3,hover_color=‘red’,hover_alpha=1,line_width=3,source=s)
b = fig.line(x=‘x’,y=‘y’,color=‘lightgrey’,line_alpha=0.3,hover_color=‘blue’,hover_alpha=1,line_width=3,source=s2)
fig.add_tools(HoverTool(renderers=[a]))
fig.add_tools(HoverTool(renderers=[b]))
code="""
if (line.glyph.line_alpha.value===0.3){
line.glyph.line_alpha.value=1;
line.glyph.line_color.value=“MYCOLO”;
} else {
line.glyph.line_alpha.value=0.3;
line.glyph.line_color.value=“lightgrey”;
}
“”"
fig.add_tools(TapTool(renderers=[a],callback=CustomJS(args={‘line’:a},code=code.replace(‘MYCOLO’,‘red’))))
fig.add_tools(TapTool(renderers=[b],callback=CustomJS(args={‘line’:b},code=code.replace(‘MYCOLO’,‘blue’))))
show(fig)
#curdoc().add_root(fig)
``