Multiple active taptools

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)

``

There is a way to do this without setting the callback on the taptool and instead using the ‘selected[‘0d’]’ of the sources. This works both with the bokeh server and with show()

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=‘tap’)

a = fig.line(x=‘x’,y=‘y’,color=‘lightgrey’,line_alpha=0.3,hover_color=‘red’,hover_alpha=1,line_width=3,name=‘a’,source=s)
b = fig.line(x=‘x’,y=‘y’,color=‘lightgrey’,line_alpha=0.3,hover_color=‘blue’,hover_alpha=1,line_width=3,name=‘b’,source=s2)

fig.add_tools(HoverTool(renderers=[a]))
fig.add_tools(HoverTool(renderers=[b]))

code = “”"
console.log(line.name);
if (line.name===‘a’) {color=‘red’;} else {color=‘blue’;}

if (line.glyph.line_alpha.value===0.3){
line.glyph.line_alpha.value=1;
line.glyph.line_color.value=color;
} else {
line.glyph.line_alpha.value=0.3;
line.glyph.line_color.value=“lightgrey”;
}
cb_obj.selected[‘0d’] = {‘indices’:Array(0),‘glyph’:null,‘get_view’:cb_obj.selected[‘0d’].get_view};
“”"

s.js_on_change(‘selected’,CustomJS(args={‘line’:a},code=code))
s2.js_on_change(‘selected’,CustomJS(args={‘line’:b},code=code))

#show(fig)
curdoc().add_root(fig)

``