Just updated to 2.3.0. Thanks for all your ongoing efforts.
Here’s my use case:
I have a CDS that holds 3 arrays of arrays being used to plot two separate multiline glyphs (using the same xs between them). My wished behaviour is on hover of either line glyphs to…
- Have the tooltips display for the hovered over line. This works for all cases (did not in 2.2.3)
- Have the hover glyph display be triggered for both the line i’m hovering over, and it’s “sister” line i.e. the other line being displayed has the same index as the line being hovered. I currently cannot get this to work
See simple example code below. You can see (by trying out the various ways of creating the hovertool I give below), you can’t get this wished behavior from both renderers simultaneously but you can get them to work as intended “one at a time”, depending on the order of defining the renderers in the renderers arg, or depending on the order of the tooltips (in the case you make two separate ones).
What’s the deal? Is this intended behavior and I’m missing something or is this an additional missing piece to the MultiLine glyph? The power of the multiline glyph is absolutely enormous for my application - a fully functioning hovertool for it would be icing on the cake.
import numpy as np
from bokeh.models import MultiLine, HoverTool,ColumnDataSource
from bokeh.plotting import figure, save
x = np.array(list(range(0,50) for x in range(3)))
y1 = [x[i]**1.2-i*10 for i in range(len(x))]
y1 = [list(i) for i in y1]
y2= [x[i]**1.3-i*10 for i in range(len(x))]
y2 = [list(i) for i in y2]
x = [list(i) for i in x]
src = ColumnDataSource({'X':x,'Y1':y1,'Y2':y2})
f = figure()
glyph1 = MultiLine(xs='X',ys='Y1',line_color='blue',line_width=1)
hglyph1 = MultiLine(xs='X',ys='Y1',line_color='red',line_width=2)
rend1 = f.add_glyph(source_or_glyph=src,glyph=glyph1,hover_glyph=hglyph1)
glyph2 = MultiLine(xs='X',ys='Y2',line_color='green',line_width=1)
hglyph2 = MultiLine(xs='X',ys='Y2',line_color='red',line_width=2)
rend2 = f.add_glyph(source_or_glyph=src,glyph=glyph2,hover_glyph=hglyph2)
#try this
hvr = HoverTool(renderers=[rend1,rend2])
f.add_tools(hvr)
# #or this
# hvr = HoverTool(renderers=[rend2,rend1])
# f.add_tools(hvr)
# # Or even try this (and toggle the two tools off an on and see how behavious changes)
# hvr1 = HoverTool(renderers=[rend1])
# f.add_tools(hvr1)
# hvr2 = HoverTool(renderers=[rend2])
# f.add_tools(hvr2)
save(f,'Test.html')