pansen pansen -4 years ago 110
Python Question

Python/Bokeh: Disable hover tool for hidden glyphs (via interactive legend)

Problem description

Since bokeh 0.12.5 it is possible to use interactive legends to hide or mute glyphs via clicking on them in the legend box. This is a great feature especially for more complex plots.

However, when used in conjunction with the hover tool, hidden glyphs should not trigger the hover tool because the user is provided with a tooltip for glyphs which are not visible (due to muting via the interactive legend).

Here is minimal code example for clarification:

import numpy as np
from bokeh.plotting import figure, show, output_notebook

x = np.arange(0, 10, 1)

p = figure(tools=["hover"])
p.line(x, x, legend="Line 1")
p.line(x, x/2, legend="Line 2")

p.legend.click_policy = "hide"

This is the resulting plot (without hiding):
enter image description here

This is the plot with Line 2 being hidden but having an active hover tooltip:enter image description here


Is there an option I'm currently missing to deactivate hover tooltips for hidden glyphs? If not, does anyone can think of a short workaround (perhaps employing CustomCS)?


Answer Source

As of bokeh 0.12.6, it is fixed. For more, see the issue in the github repo here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download