Changing the Color of HoverTool Text to Match DataSource Color Field of Current Target

I am trying to figure out how to set the text color of the HoverTool tooltips text to match the color of the glyph whose source it is currently displaying information from. I have been unable to find where in the documentation the property I can use with cb_obj to set that color in some CustomJS code, or how to tap into the Source information used by the HoverTool to generate the tooltips.

BTW, in the tool tip these two choices give identical results. It appears that the hex code for the color will be shown either way:

hover.tooltips = [
("Color", "$color[swatch]:Color"),
("Color", "$color[hex, swatch]:Color")
]
1 Like

The basic auto-generated tooltip is not very configurable to any degree. If you want to alter the appearance, etc. you should pas a custom tooltip template:

https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#custom-tooltip

I expect that means you are passing hex values to begin with. The hex value there causes color2hex to be applied, which is a no-op in that case.

1 Like

@Bryan If the default hovertool tooltip template is also written as an HTML template, would it be possible to get the source HTML to hack on?

It is not, it is constructed programmatically by building DOM elements explicitly.

1 Like