Limit the Hover tooltip to display single tooltip on overlapping data

Hello, I have the same situation and question as presented in this stack overflow: https://stackoverflow.com/questions/68513132/displaying-only-one-tooltip-when-using-the-hovertool-in-bokeh

Essentially when data is close together, I want to avoid showing the stack of tooltips and only display the nearest one. I have tried all the techniques that I have found that the link above also references to but none of them seem to work in Bokeh 3 anymore.

I currently have my own CustomHTML for the tool tip and is very similar to the example expressed in the stack overflow question.

Am I missing a new setting that might make this easier? Or is an approach like this still required?

Thanks for any help

There is some in-flight work to make improvements in this area, but they are still under discussion / not merged. e.g. this PR which might land for 3.8 (but may also get delayed)

Add support for filters, sorters and limits to `HoverTool` by mattpap · Pull Request #14484 · bokeh/bokeh · GitHub

1 Like

Great thanks for pointing that out. Hopefully it gets in sooner rather than later.

Does anyone know if there is a ‘hacky’ solution like those that were detailed before?

The solution you refer to on SO seems OK to me. I have sometimes used a setup with a regular CustomJS callback and a Label or Div element in a corner of a plot. The HoverTool callback gets the hovered indices as an array with cb_data.index.indices (scatter glyph). I can choose which index I want (if for some reason I want a specific). Then I update the text with the info I want to display.

2 Likes

Thank you for saying this, it made me look again and I had missed one bit on the div the @x{custom}.

I can confirm this works as of 3.7.3

Thanks very much

1 Like