Setting hover tool on specific renderers

I have a scatter plot containing multiple renderers that update on a slider value. I’m having an issue setting the hover tool to work on one renderer only.

I would expect something like below would be sufficient:

#build glyphs perSliderInc

rend_source = sourceSliderInc[’_%s’ % listSliderInc[0]]

circle1_glyph = Circle(

x=‘X2’, y=‘Y2’, radius = ‘SIZEB’,

fill_color=None,

line_color=‘COLORB’, line_width=‘LINEB’, line_alpha=‘ALPHA’)

fig.add_glyph(rend_source, circle1_glyph)

circle2_glyph = Circle(

x=‘X’, y=‘Y’, size=‘SIZED’,

fill_color=‘COLORMAIN’,fill_alpha=‘ALPHA’,

line_color=‘COLORSUB’, line_width=3, line_alpha=‘ALPHA’)

fig.add_glyph(rend_source, circle2_glyph)

hover = HoverTool(tooltips=tooltips, renderers=[circle1_glyph])

fig.add_tools(hover)

But I get this error:

ValueError: expected an element of List(Instance(Renderer)), got seq with invalid items [<bokeh.models.markers.Circle object at 0x0000000015C45A90>]

Any ideas on what I’m overlooking?

So the Circle is a Glyph, but you need to pass the GlyphRenderer, that's the object that coordinates the possibly multiple versions of Circle needed to do things like selection and hover highlighting, as well as coordinate a single set of screen-transformed data for them to share. Long/short, you are passing the wrong thing. :slight_smile: The "add_glyph" method returns the renderer for the glyph, that is what you want to configure the tool with.

I note the docstring here :

  https://github.com/bokeh/bokeh/blob/master/bokeh/models/plots.py#L283

is out of date, it should state that a GlyphRenderer is returned. Would you mind making a PR to update that? The team is scrambling for a code freeze so help with little things like this is actually very valuable (otherwise easy to forget/overlook).

Thanks,

Bryan

···

On Jun 16, 2016, at 12:20 PM, [email protected] wrote:

I have a scatter plot containing multiple renderers that update on a slider value. I'm having an issue setting the hover tool to work on one renderer only.

I would expect something like below would be sufficient:

    build glyphs perSliderInc
    rend_source = sourceSliderInc['_%s' % listSliderInc[0]]
    circle1_glyph = Circle(
        x='X2', y='Y2', radius = 'SIZEB',
        fill_color=None,
        line_color='COLORB', line_width='LINEB', line_alpha='ALPHA')
    fig.add_glyph(rend_source, circle1_glyph)
    circle2_glyph = Circle(
        x='X', y='Y', size='SIZED',
        fill_color='COLORMAIN',fill_alpha='ALPHA',
        line_color='COLORSUB', line_width=3, line_alpha='ALPHA')
    fig.add_glyph(rend_source, circle2_glyph)
    hover = HoverTool(tooltips=tooltips, renderers=[circle1_glyph])
    fig.add_tools(hover)

But I get this error:

ValueError: expected an element of List(Instance(Renderer)), got seq with invalid items [<bokeh.models.markers.Circle object at 0x0000000015C45A90>]

Any ideas on what I'm overlooking?

--
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/c4bbe47e-6c14-4f42-8890-30a2fce6e250%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.