bokeh: [BUG] HoverTool in 'vline' mode doesn't work with vertical segments
Bokeh version: 1.4 Python version: 3.7.5 Browser: Firefox / Chromium OS: Linux
When adding a HoverTool with mode='vline' to a plot with vertical segments, the tooltip is not displayed.
Example code:
from bokeh.io import output_file, save
from bokeh.models import HoverTool
from bokeh.plotting import figure
x = [1, 2, 3, 4]
y0 = [1] * 4
y1 = [2] * 4
fig = figure(tools=[HoverTool(mode='vline')])
fig.segment(x, y0, x, y1)
output_file('vline.html')
save(fig)
Screenshot:

About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (17 by maintainers)
OK well let’s make a PR and go from there (the other reason to make a PR earlier is that it is much easier for other people to try out a PR)
@kumaran-14 the span coordinate geometry comes in as pixel coordinates. You can see that scale
invertfunction is use to convert to back to “data space” (so that the spatial index an be used to get a first batch of potential hits). Scales also have acomputemethod, which goes in the opposite direction, converting from data space to pixel space. You can use that to convert segment data coordinates to pixel coordinates in a similar way, for the final comparison.@kumaran-14 perhaps the comparisons can be changed to be in “pixel-space” instead of “data-space”? In which case a fixed epsilon of e.g. 0.5 (of a pixel) on either side might be sufficient.
@kumaran-14 Any one can take up any issue they please 😃 I think it would be great if you are able to look in to this. Specifically, the hit testing for
Segmentglyphs agains “spans” (e.g. a vline or hline) is here:https://github.com/bokeh/bokeh/blob/master/bokehjs/src/lib/models/glyphs/segment.ts#L95-L124
That’s probably what would need to be modified.