Check box chooses lines

Hi All

I have attempted to create a plot (code attached) which displays lines according to a check-box being checked. While I can add the lines, I can’t seem to remove them.

Is there a simple way to rectify this?

Kind regards

CheckBoxChart.py (1.78 KB)

Hi KK,

I’m new to Bokeh but I hacked on the code you attached and came close.

As far as I can tell, in your checkbox hander you are just drawing and re-drawing the lines and not really affecting their visibility.

I moved the plot.line() calls out of the checkbox handler and re-wrote it as:

def checkbox_group_handler(active):
for i,renderer in enumerate(plot.select(dict(type=GlyphRenderer))):
renderer.glyph.visible = bool(i in active)
session.store_document(document)

This actually sort of works, but only if you refresh the brower tab after checking or unchecking a box.

Maybe someone else can get us the rest of the way?

CheckBoxChart.py (1.99 KB)

···

On Friday, March 6, 2015 at 8:17:06 PM UTC-6, KK wrote:

Hi All

I have attempted to create a plot (code attached) which displays lines according to a check-box being checked. While I can add the lines, I can’t seem to remove them.

Is there a simple way to rectify this?

Kind regards

Is there any update on this? Did you guys ever get it working properly?

When I try to execute this via bokeh-server --script command I am getting this error:

Traceback (most recent call last):

File “C:\Anaconda\Scripts\bokeh-server-script.py”, line 6, in

bokeh.server.run()

File “C:\Anaconda\lib\site-packages\bokeh\server_init_.py”, line 175, in run

start_server(args)

File “C:\Anaconda\lib\site-packages\bokeh\server_init_.py”, line 179, in start_server

start.start_simple_server(args)

File “C:\Anaconda\lib\site-packages\bokeh\server\start.py”, line 52, in start_simple_server

configure_flask(config_argparse=args)

File “C:\Anaconda\lib\site-packages\bokeh\server\configure.py”, line 76, in configure_flask

imp.load_source(“_bokeh_app”, script)

File “CheckBoxChart_r1.py”, line 73, in

hbox = HBox(children=[plot, checkbox_group])

File “C:\Anaconda\lib\site-packages\bokeh\deprecate.py”, line 289, in deprecatedFunction

return function(*args, **kwargs)

File “C:\Anaconda\lib\site-packages\bokeh\plotting.py”, line 40, in HBox

return hplot(*args, **kwargs)

File “C:\Anaconda\lib\site-packages\bokeh\io.py”, line 421, in hplot

layout = HBox(children=list(children), **kwargs)

TypeError: Viewable object got multiple values for keyword argument ‘children’

``

···

On Monday, March 16, 2015 at 2:51:44 PM UTC-7, Erik wrote:

Hi All

I have attempted to create a plot (code attached) which displays lines according to a check-box being checked. While I can add the lines, I can’t seem to remove them.

Is there a simple way to rectify this?

Kind regards

Hi KK,

I’m new to Bokeh but I hacked on the code you attached and came close.

As far as I can tell, in your checkbox hander you are just drawing and re-drawing the lines and not really affecting their visibility.

I moved the plot.line() calls out of the checkbox handler and re-wrote it as:

def checkbox_group_handler(active):
for i,renderer in enumerate(plot.select(dict(type=GlyphRenderer))):
renderer.glyph.visible = bool(i in active)
session.store_document(document)

This actually sort of works, but only if you refresh the brower tab after checking or unchecking a box.

Maybe someone else can get us the rest of the way?

On Friday, March 6, 2015 at 8:17:06 PM UTC-6, KK wrote: