How to make hoverTool only do hit test on certain glyphs?

289 views Asked by At
fig = figure(plot_width=1000, plot_height=500, tools=[HoverTool()])
fig.circle([1,2,3], [1,2,3], color='red')
fig.circle([1,2,3], [2,3,4], color='blue')
show(fig)

I would like the hoverTool only apply to the red circles.

The document says:

renderers
property type: List(Instance(Renderer))

An explicit list of renderers to hit test again. If unset, defaults to all renderers on a plot.

However, it seems the Circle glyph is not a renderer.

1

There are 1 answers

0
Luke Canavan On BEST ANSWER

You'll have to add a name="foo" attr to each circle glyph then pass the names of the renderers that you want to interact with to the "names" attr of HoverTool

Such as:

fig = figure(plot_width=1000, plot_height=500, tools=[HoverTool(names=['reds'])])
fig.circle([1,2,3], [1,2,3], color='red', name='reds')
fig.circle([1,2,3], [2,3,4], color='blue', name='blues')
show(fig)