Configuring hover tool on high-level Bar chart

Hello,

I am trying to configure the hovertool on a high level Bar chart with the following code:

data = {“z”: [1, 5, 12, 4, 2], “w”: [1, 2, 3, 4, 5]}

p = Bar(data, width=500, height=500)

hover = HoverTool(

tooltips = [

(“index”, “$index”),

("(x,y)", “($x, $y)”),

(“w”, “@w”),

(“z”, “@z”),

]

)

p.add_tools(hover)

show(p)

It render correctly and when I hover over one of the bars, it shows the data for both ‘w’ and ‘z’ in that index. I would like to configure it to only show the data for the bar I am hovering over (i.e. for the ‘w’ bar show the ‘w’ data and for the ‘z’ bar show the ‘z’ data).

Thanks for any advice,

John

Has there been any response to this? I am trying to work this out as well?

···

On Friday, June 12, 2015 at 4:36:59 PM UTC-4, John Fries wrote:

Hello,

I am trying to configure the hovertool on a high level Bar chart with the following code:

data = {“z”: [1, 5, 12, 4, 2], “w”: [1, 2, 3, 4, 5]}

p = Bar(data, width=500, height=500)

hover = HoverTool(

tooltips = [

(“index”, “$index”),

(“(x,y)”, “($x, $y)”),

(“w”, “@w”),

(“z”, “@z”),

]

)

p.add_tools(hover)

show(p)

It render correctly and when I hover over one of the bars, it shows the data for both ‘w’ and ‘z’ in that index. I would like to configure it to only show the data for the bar I am hovering over (i.e. for the ‘w’ bar show the ‘w’ data and for the ‘z’ bar show the ‘z’ data).

Thanks for any advice,

John

By default a hover tool works on every glyph renderer that a Plot has. You've created one hover tool, that is configured to show both "w" and "z", so it shows both, whenever a user hovers over any glyph.

It is definitely possible to add multiple hover tools to one plot, each configured differently (e.g. one for "w" and another for "z"), and each configured to only respond to a certain subset of glyph renderers (e.g., one for the "w" bars and another for the "z" bars). I think right now however, it would be easier to do this with the bokeh.plotting interface, using the "rect" glyph functions.

The issue for Charts is that they are very high level, so they do many things on behalf of the user. To add two hovers like this to a chart, I think you woudl have to go digging around a bit in the Chart internals to find the renderers you need. This is not impossible, but personally I would turn to bokeh.plotting first. It's offers a little more control for probably only a couple of extra lines of code. Nick Roth may chime in with some other ideas or information I have overlooked.

It would be a good feature to be able to do this easily from bokeh.charts, though. One of the issues would be: how do you "spell" this easily in python. So if you have any suggestions for what sort of interface would be best for expressing this kind of split-hover-tool usage, please let us know.

Bryan

···

On Dec 3, 2015, at 10:22 AM, [email protected] wrote:

Has there been any response to this? I am trying to work this out as well?

On Friday, June 12, 2015 at 4:36:59 PM UTC-4, John Fries wrote:
Hello,

I am trying to configure the hovertool on a high level Bar chart with the following code:

data = {"z": [1, 5, 12, 4, 2], "w": [1, 2, 3, 4, 5]}
p = Bar(data, width=500, height=500)

hover = HoverTool(
    tooltips = [
        ("index", "$index"),
        ("(x,y)", "($x, $y)"),
        ("w", "@w"),
        ("z", "@z"),
    ]
)

p.add_tools(hover)
show(p)

It render correctly and when I hover over one of the bars, it shows the data for both 'w' and 'z' in that index. I would like to configure it to only show the data for the bar I am hovering over (i.e. for the 'w' bar show the 'w' data and for the 'z' bar show the 'z' data).

Thanks for any advice,
John

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d6947108-eff7-4616-bd81-42d5ef332626%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Also, see some specific technical guidance for possibly working directly with charts here:
  
  custom Bar chart hover tooltips · Issue #2965 · bokeh/bokeh · GitHub

···

On Dec 3, 2015, at 10:31 AM, Bryan Van de Ven <[email protected]> wrote:

By default a hover tool works on every glyph renderer that a Plot has. You've created one hover tool, that is configured to show both "w" and "z", so it shows both, whenever a user hovers over any glyph.

It is definitely possible to add multiple hover tools to one plot, each configured differently (e.g. one for "w" and another for "z"), and each configured to only respond to a certain subset of glyph renderers (e.g., one for the "w" bars and another for the "z" bars). I think right now however, it would be easier to do this with the bokeh.plotting interface, using the "rect" glyph functions.

The issue for Charts is that they are very high level, so they do many things on behalf of the user. To add two hovers like this to a chart, I think you woudl have to go digging around a bit in the Chart internals to find the renderers you need. This is not impossible, but personally I would turn to bokeh.plotting first. It's offers a little more control for probably only a couple of extra lines of code. Nick Roth may chime in with some other ideas or information I have overlooked.

It would be a good feature to be able to do this easily from bokeh.charts, though. One of the issues would be: how do you "spell" this easily in python. So if you have any suggestions for what sort of interface would be best for expressing this kind of split-hover-tool usage, please let us know.

Bryan

On Dec 3, 2015, at 10:22 AM, [email protected] wrote:

Has there been any response to this? I am trying to work this out as well?

On Friday, June 12, 2015 at 4:36:59 PM UTC-4, John Fries wrote:
Hello,

I am trying to configure the hovertool on a high level Bar chart with the following code:

data = {"z": [1, 5, 12, 4, 2], "w": [1, 2, 3, 4, 5]}
p = Bar(data, width=500, height=500)

hover = HoverTool(
   tooltips = [
       ("index", "$index"),
       ("(x,y)", "($x, $y)"),
       ("w", "@w"),
       ("z", "@z"),
   ]
)

p.add_tools(hover)
show(p)

It render correctly and when I hover over one of the bars, it shows the data for both 'w' and 'z' in that index. I would like to configure it to only show the data for the bar I am hovering over (i.e. for the 'w' bar show the 'w' data and for the 'z' bar show the 'z' data).

Thanks for any advice,
John

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d6947108-eff7-4616-bd81-42d5ef332626%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.