Hover - settings

Hi, I’ve produced 2 graphs, both use the same CDS. The behavior is interesting and I’d like to understand some machinery behind it.

  1. is it possible to display corresponding info on the graph that is not active (in this particular case, value on the red bar / info on the curve plots) ?
  2. how to disconnect both graphs (bars / curve)? It didn’t expect initially any interactions. What is interesting is that hover is applied to selected plot only.
  3. is it possible to distinguish info between plots (cumulative, proportion) ?

right graph active

left graph active

  1. Bokeh is pretty extensible so almost all questions about possibility of something could be answered positively. But some approaches would require a significant amount of code, like 100s of lines of JavaScript for example. With that being said, it would be pretty hard to have a proper tooltip over the inactive plot. But it’s very easy to just add a label to the plot (either as a Label annotation or via plot.text) and alter its properties, including visible, when you inspect something
  2. They are connected because you share data sources. Maybe other models, like ranges - impossible to tell without the code
  3. No idea what you mean by “distinguish info between plots”

I suppose CDSView is partly a solution as well. OK. This is something I have to dig into deeper.

point 3)
We have 2 plots - please see the legend - (proportion, cumulative). Both share same data and hover is set as visible above the screen. One should show PC and proportion and the other PC and cumulative.

You don’t need CDSView to display a piece of text - you can just alter properties of a glyph/annotation in a CustomJS callback.

Ah, then it’s the same deal as before. To have different tooltips means having different HoverTools because a HoverTool basically inspect a row in a data source, and that row always has all of the columns. And triggering one HoverTool from another is not trivial, there will be quite some amount of JS code involved.

I take my words back - it’s absolutely possible to display different tooltips on the same plot where only one data source is involved:

from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show

s = ColumnDataSource({
    'index': [1, 2, 3, 4, 5],
    'a': [10, 20, 30, 40, 50],
    'b': [20, 10, 10, 10, 10]
})

hta = HoverTool(tooltips=[('Index', '@index'),
                          ('A', '@a')],
                mode='vline')
htb = HoverTool(tooltips=[('Index', '@index'),
                          ('B', '@b')],
                mode='vline')
p = figure(tools=[hta, htb])
ar = p.circle('index', 'a', color='red', source=s)
br = p.circle('index', 'b', color='green', source=s)
hta.renderers = [ar]
htb.renderers = [br]

show(p)

But it means that in my case I’ll have 2 Hover icons? Right?
Is there any way to avoid this? Imagine 10 ‘independent’ glyps.

Yeah, that’s the only downside. The easiest way to prevent that is to just hide all of the HoverTools via custom CSS. The only other way I can think of is create some custom models that, again, involve some amount of JS.

Please consider ‘merge hover icons’ option.

The feature request already exists: Group hover tool toolbar icons · Issue #5497 · bokeh/bokeh · GitHub