I really would like the information to be as close to the mouse pointer (and the users attention area) as I can
Div next to the plot, you could also use a
text glyph or
Label annotation to draw directly on the canvas. If you can require users to actually click on the point that they want to interrogate, that will be much simpler. Clicking will set the the selection index in the
source.selected.indices property. Then a callback for the data source change could just look there to get the necessary index needed update the
Div, text or label as appropriate.
There’s probably a roundabout way to do it with hover only, but it would not be pretty, since inspection information is not currently publicly available. You would have to make a
HoverTool.callback to set the inspection indices on a new
DataModel (Bokeh >=2.3 only), and then the data source callback could look at the
DataModel get the index of the hovered point.
A reasonable GitHub Issue here would be regarding making the hover inspection hit-testing public, which would make same (simpler) solutions as for selections possible. We have not done so yet because, done naively, it would result in excessive data updates (i.e. every single mouse move). But the information is there, so we would just need to find some way to be more clever about it, or at least only turned on when explicitly asked.
Seems like I’m really pushing bokeh to its (intended) limit.
There’s an infinite amont of things that could be implemented. So most development is driven off of expressed user need, and no one has ever asked for this before. But speaking frankly, I’d have to say it’s unlikely we would consider API to trigger mouse hovertool updates manually, even if asked:
- very uncommon need (low user impact / benefit)
- very hard to test (high maintenance burden)
This combination is about the worst-case scenario for any potential feature ask.
What is much more likely is to add a “sticky” tooltip option that can be completely manually controlled by users:
Feature Request: HoverTool tooltips stick to a point on click. · Issue #5724 · bokeh/bokeh · GitHub
There is clear interest and utility in this, but there’s been a lot of discussion and back and forth and not enough agreement, so nothing has been done yet.