☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Change Hover title depending on positive and negative X and Y values

Community Support
somebody
somebody

I’m wondering if it is possible to change titles for @x and @y values depending if they are possitive or negative.
This is what I have

TOOLTIPS = [("Point ", "$index"), (pressure, "@y"), (axial_force, "@x")]
fig = figure(sizing_mode='stretch_both', tooltips=TOOLTIPS)

And this is what I need:

if @x>0:
    pressure = "Internal Pressure"
else:
    pressure = "External Pressure"

if @y>0:
    axial_force = "Tension"
else:
    axial_force = "Compression"
⌁   Link to post
gmerritt123
gmerritt123

Check out this very recent thread: Hover Tool dynamic fields - #5 by gmerritt123

You can basically set up your tooltips in a dictionary, one for each case, pass that tooltip dict, the hovertool, and the datasource to CustomJS that is trigged on source inspected indices.change (i.e. on hover). The CustomJS looks at the value of the inspected index, and depending on the value, assigns the tooltip you want to display.

⌁   Link to post

End of archived discussion · Replies are disabled