Legend entry for text renderer causes error.

I get the error:

“Uncaught TypeError: Cannot read property ‘set_value’ of undefined at e.n.TextView.e.draw_legend_for_index (bokeh-0.12.13.min.js:1)”

when I try to add a legend entry for text glyphs:

import bokeh.plotting as BPlotting
x = range(5)
y = x
t = [str(i) for i in y]
source = BPlotting.ColumnDataSource(data=dict(x=x, y=y, t=t))
p = BPlotting.figure()
p.circle(‘x’, ‘y’, source=source, muted_alpha=0.2, legend=‘circle’)
p.text(‘x’, ‘y’, source=source, text=‘t’, muted_alpha=0.2, legend=‘text’)
p.line(‘x’, ‘y’, source=source, muted_alpha=0.2, legend=‘line’)
p.legend.location = “top_left”
p.legend.click_policy = “mute”
BPlotting.output_file(‘text.html’)
BPlotting.show§

Note that even though the third legend item (‘line’) isn’t visible, it’s still clickable to toggle muting.

Bokeh bug? or am I doing something wrong?

thanks

albert.

Hi,

Seems like a bug. I'm not aware that we've ever implemented legend for text, since it wasn't clear what to render as the "prototype" in the legend itself. But in that case it should just no-op and not cascade a failure to other legends. In any case a detailed GH issue is appropriate.

Thanks,

Bryan

···

On Dec 19, 2017, at 14:21, Albert Chau <[email protected]> wrote:

import bokeh.plotting as BPlotting
x = range(5)
y = x
t = [str(i) for i in y]
source = BPlotting.ColumnDataSource(data=dict(x=x, y=y, t=t))
p = BPlotting.figure()
p.circle('x', 'y', source=source, muted_alpha=0.2, legend='circle')
p.text('x', 'y', source=source, text='t', muted_alpha=0.2, legend='text')
p.line('x', 'y', source=source, muted_alpha=0.2, legend='line')
p.legend.location = "top_left"
p.legend.click_policy = "mute"
BPlotting.output_file('text.html')
BPlotting.show(p)