1
votes

I have 3 plots on the same graph (Bokeh 0.12.7)

I want to show a single tooltip with the summary of all data for the 3 graphs, like this:

single tooltip with summary

but I obtain 2/3 overlapped (and identical) tooltips whenever the mouse pointer is too close to multiple plots, like in this case:

enter image description here

It is possible to restrict the tooltip to a single plot, but this means that nothing happens if the mouse pointer touches the other two: in the following code I use the param names in HoverTool to apply the tooltip to the first plot only.

Is there a way to have a single hovertool that reacts to all plots?

COMMON_PARAM = dict(x="date_time", source=self.data_source, line_alpha=GRAPH_LINE_ALPHA, line_width=GRAPH_LINE_WIDTH)

line1 = self.figure.line(y=f1,
                         line_color=GRAPH_LINE_1_COLOR,                                                  
                         name="line_with_hovertool",
                         **COMMON_PARAM)

line2 = self.figure.line(y=f2,
                         line_color=GRAPH_LINE_2_COLOR,
                         **COMMON_PARAM)

line3 = self.figure.line(y=f3),
                         line_color=GRAPH_LINE_3_COLOR,
                         **COMMON_PARAM)

hover = HoverTool(
    names=["line_with_hovertool"],    # applies only to line1
    tooltips=
    """
    ....
    """)

self.figure.add_tools(hover)
1

1 Answers

0
votes

A possible work around is to change the hover mode to "vline". This means the hover will appear as the user moves their mouse from left to right anywhere on the plot window. Then you can restrict the hover tooltip to just on glyph as you have already done.

Obviously if that is not desirable I am not sure if there is a better way currently, so it may just have to work in the short term/until that is addressed.

Vline can be set as per bokeh documents under the "mode" attribute when you first instantiate the hovertool. http://docs.bokeh.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool.mode