2.3.0 - Multiline hover... Not sure about intended behaviour/if it's fully "fixed" yet

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…

  1. Have the tooltips display for the hovered over line. This works for all cases (did not in 2.2.3) :slight_smile:
  2. 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 :frowning:

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')

You are sharing a data source between glyph renderers, so you are also sharing inspection indices. Thus inspection on one glyph renderer, triggers its hover glyph but also the other glyph renderer’s hover glyph. This is by design, though I’m not sure if the is the best design, if you only want to share data between glyph renderers.

Thanks for getting back to me. Yes, that is what I want to happen, but that is not what happens. If I instantiate a HoverTool like this (i.e. first example in my code above):

hvr = HoverTool(renderers=[rend1,rend2])

, hovering over “rend2” (the green lines) triggers the hover glyph on rend1 for the correct line:

But if I hover over “rend1” (the blue lines), I don’t trigger the hover glyph for either of them:

If I flip the order of the renderers in the list:

hvr = HoverTool(renderers=[rend2,rend1])

The opposite happens - the hover glyphs are trigger upon hover of rend1, but not rend2. This is what I’m getting at…