Trigger HoverTool on hover text string in Div

Wondering if it’s possible for me to trigger a hovertool when hovering over a specific text string in a Div object. My text in the div is fairly technical jargon and I’d like to give users the ability to hover over a particular phrase/word and get a hovertool “definition” of that thing.

My other thought/idea for this would be to somehow trigger a js callback either on hover or on click of a specific text string within the div - which would update another div (say, on the side of the plot or something) with the definition lookup.

Any thoughts/help much appreciated. Thanks!

The HoverTool only functions on plot canvas, not any other DOM elements or widgets (e.g. not with Div).

Wow talk about a fast response! Thanks. What about option 2? Can I embed some html/css syntax in the div text to have it “recognize” certain words and trigger a callback when clicked? According to the documentation I can trigger js_event_callbacks on the whole div object… but not on specific text within the div itself eh?

Yes, Bokeh JS callbacks only pertain to property values, e.g. the entire text of the Div. I won’t say it’s impossible to imagine some way to do what you are suggesting, but it would require running your own JS code outside Bokeh, and I am afraid I don’t really have any concrete suggestions beyond that.

Thanks, you should see another showcase post from me soon :slight_smile:

2 Likes