HoverTool on one glyph only

I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line. If I remove the renderers=[…] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I’m trying at the moment:

‘’’
testing hover tool on multiple glyphs

‘’’

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

PLOT = figure(tools=[‘pan’])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])
PLOT.tools.append(HT)
output_file(“hovertest.html”, title=“testing hover tool”)

show(PLOT)

``

Hi,

···

On Mon, Apr 25, 2016 at 8:18 AM, [email protected] wrote:

I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line.

that should work. Which version of bokeh do you use?

Mateusz

If I remove the renderers=[…] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I’m trying at the moment:

‘’’
testing hover tool on multiple glyphs

‘’’

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

PLOT = figure(tools=[‘pan’])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])
PLOT.tools.append(HT)
output_file(“hovertest.html”, title=“testing hover tool”)

show(PLOT)

``

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/f51cc839-a04a-4b16-946e-d446bcd907d5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi

The issue might be related to appending a tool. I’m using Bokeh 0.11.1. I modified Chris’ example a bit:

from bokeh.io import output_notebook
output_notebook()

from bokeh.io import show
from bokeh.plotting import figure
from bokeh.models import HoverTool

p = figure(tools=[‘pan’])
glyph_1 = p.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
ht = HoverTool()
p.tools.append(ht)
show§

``

Error message in the notebook:

Javascript error adding output!

TypeError: Cannot read property ‘get’ of null

See your browser Javascript console for more details.

And the last few lines of the console:

Bokeh: all callbacks have finished
Bokeh: BokehJS loaded, going straight to plotting
TypeError: Cannot read property ‘get’ of null(…)
Could not open comm – Error: Class 077b0c01-d724-4681-bddd-915c74444277 not found in registry (…)
Couldn’t process kernel message WrappedError {stack: “Error: Could not open comm↵ at new Error (native)…n.js?v=5583f76ed439d168d24e1b201697c328:12840:33↵”, message: “Could not open comm”, error_stack: Array[2]}

After this, all bokeh rendering in the notebook is broken, even plots in other cells that previously worked, with console messages “Could not open comm …” and “Couldn’t process kernel message …”.

cheers,

Dennis

···

On Monday, April 25, 2016 at 7:40:58 AM UTC-7, mateusz.paprocki wrote:

Hi,

On Mon, Apr 25, 2016 at 8:18 AM, [email protected] wrote:

I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line.

that should work. Which version of bokeh do you use?

Mateusz

If I remove the renderers=[…] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I’m trying at the moment:

‘’’
testing hover tool on multiple glyphs

‘’’

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

PLOT = figure(tools=[‘pan’])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])
PLOT.tools.append(HT)
output_file(“hovertest.html”, title=“testing hover tool”)

show(PLOT)

``

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/f51cc839-a04a-4b16-946e-d446bcd907d5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

FWIW I think the comms issue is unrelated, but also fixed on master. Comms connects were wrapped in a try/catch, so if they fail then push_notebook won't work, but things should not fall over anymore.

Bryan

···

On Apr 26, 2016, at 1:27 PM, Dennis O'Brien <[email protected]> wrote:

Hi

The issue might be related to appending a tool. I'm using Bokeh 0.11.1. I modified Chris' example a bit:

from bokeh.io import output_notebook
output_notebook()

from bokeh.io import show
from bokeh.plotting import figure
from bokeh.models import HoverTool

p = figure(tools=['pan'])
glyph_1 = p.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
ht = HoverTool()
p.tools.append(ht)
show(p)

Error message in the notebook:

Javascript error adding output!
TypeError: Cannot read property 'get' of null
See your browser Javascript console for more details.

And the last few lines of the console:

Bokeh: all callbacks have finished
Bokeh: BokehJS loaded, going straight to plotting
TypeError: Cannot read property 'get' of null(…)
Could not open comm -- Error: Class 077b0c01-d724-4681-bddd-915c74444277 not found in registry (…)
Couldn't process kernel message WrappedError {stack: "Error: Could not open comm↵ at new Error (native)…n.js?v=5583f76ed439d168d24e1b201697c328:12840:33↵", message: "Could not open comm", error_stack: Array[2]}

After this, all bokeh rendering in the notebook is broken, even plots in other cells that previously worked, with console messages "Could not open comm ..." and "Couldn't process kernel message ...".

cheers,
Dennis

On Monday, April 25, 2016 at 7:40:58 AM UTC-7, mateusz.paprocki wrote:
Hi,

On Mon, Apr 25, 2016 at 8:18 AM, <[email protected]> wrote:
I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line.

that should work. Which version of bokeh do you use?

Mateusz

If I remove the renderers=[...] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I'm trying at the moment:

'''
testing hover tool on multiple glyphs

'''

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

PLOT = figure(tools=['pan'])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])
PLOT.tools.append(HT)
output_file("hovertest.html", title="testing hover tool")

show(PLOT)

--
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/f51cc839-a04a-4b16-946e-d446bcd907d5%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/c31210f8-98f0-4956-8f63-60dd0583c1f0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi everyone,

The OP’s question is very similar to something I’ve been trying to do, with the added complication of having the renderers for the hover tool change depending on the selection in a MultiSelect interaction. To be a little more concrete, I have a chart with dozens of lines and the user can select which lines to plot with the MultiSelect tool. Unfortunately, the tooltips from the hidden lines show up when I mouse over them. I accomplish the hiding/revealing of the lines by modifying the each glyph’s ‘visible’ attribute in a callback tied to the multiselect, but I haven’t been able to find a similar way to disable/enable the tooltips. Here’s the callback I’ve been working with in case that’s useful (labels is an object I pass to the callback with the line objects generated in Python):

var callback = cb_obj.get("callback");
var args = callback.get("args");
var selected = cb_obj.get('value');
var labelData = labels.get("data");
var labelNames = labelData.labels;
var numLabels = labelNames.length;
var arrayLength = labelNames;
var i;
var label;
var glyphRenderer;

for (i = 0; i < numLabels; i += 1) {
    label = labelNames[i];
    glyphRenderer = args[label];
    glyph = glyphRenderer.get("glyph");
    if (selected.indexOf(label) >= 0) {
        glyph.set("visible", true);
    } else {
        glyphRenderer.set("hover_glyph",null);
        glyph.set("visible", false);
    }
    glyphRenderer.trigger("change");

}

``

Happy to clarify anything, and thanks in advance for your advice.

···

On Tuesday, April 26, 2016 at 11:30:32 AM UTC-7, Bryan Van de ven wrote:

FWIW I think the comms issue is unrelated, but also fixed on master. Comms connects were wrapped in a try/catch, so if they fail then push_notebook won’t work, but things should not fall over anymore.

Bryan

On Apr 26, 2016, at 1:27 PM, Dennis O’Brien [email protected] wrote:

Hi

The issue might be related to appending a tool. I’m using Bokeh 0.11.1. I modified Chris’ example a bit:

from bokeh.io import output_notebook

output_notebook()

from bokeh.io import show

from bokeh.plotting import figure

from bokeh.models import HoverTool

p = figure(tools=[‘pan’])

glyph_1 = p.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)

ht = HoverTool()

p.tools.append(ht)

show§

Error message in the notebook:

Javascript error adding output!

TypeError: Cannot read property ‘get’ of null

See your browser Javascript console for more details.

And the last few lines of the console:

Bokeh: all callbacks have finished

Bokeh: BokehJS loaded, going straight to plotting

TypeError: Cannot read property ‘get’ of null(…)

Could not open comm – Error: Class 077b0c01-d724-4681-bddd-915c74444277 not found in registry (…)

Couldn’t process kernel message WrappedError {stack: “Error: Could not open comm↵ at new Error (native)…n.js?v=5583f76ed439d168d24e1b201697c328:12840:33↵”, message: “Could not open comm”, error_stack: Array[2]}

After this, all bokeh rendering in the notebook is broken, even plots in other cells that previously worked, with console messages “Could not open comm …” and “Couldn’t process kernel message …”.

cheers,

Dennis

On Monday, April 25, 2016 at 7:40:58 AM UTC-7, mateusz.paprocki wrote:

Hi,

On Mon, Apr 25, 2016 at 8:18 AM, [email protected] wrote:

I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line.

that should work. Which version of bokeh do you use?

Mateusz

If I remove the renderers=[…] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I’m trying at the moment:

‘’’

testing hover tool on multiple glyphs

‘’’

from bokeh.plotting import figure, show, output_file

from bokeh.models import HoverTool

PLOT = figure(tools=[‘pan’])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)

GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])

PLOT.tools.append(HT)

output_file(“hovertest.html”, title=“testing hover tool”)

show(PLOT)


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/f51cc839-a04a-4b16-946e-d446bcd907d5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/c31210f8-98f0-4956-8f63-60dd0583c1f0%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

plot.add_tools(ht)

And that works on 0.11.x and 0.12.x from personal experience, on dozens of custom charts. Side note, uppercase names are usually for “constants”.

Regards,

Francois

···

On Monday, April 25, 2016 at 9:47:14 AM UTC-4, [email protected] wrote:

I am trying to get the hover tool to only show for one glyph type on a chart. I have tried setting the renderer but seem to get a blank output when I add this line. If I remove the renderers=[…] argument from HoverTool call then it works as usual but hover tool shows for all glyphs on the figure.

Here is an example of what I’m trying at the moment:

‘’’
testing hover tool on multiple glyphs

‘’’

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

PLOT = figure(tools=[‘pan’])

GLYPH1 = PLOT.circle(x=[0, 1, 2], y=[0, 1, 2], size=10)
GLYPH2 = PLOT.circle(x=[4, 5], y=[4, 5], size=10)

HT = HoverTool(renderers=[GLYPH2])
PLOT.tools.append(HT)
output_file(“hovertest.html”, title=“testing hover tool”)

show(PLOT)

``

I always use add_tools, ie.: