
Hi, I am trying to see if there is a simple CheckBoxGroup example to toggle visibility over a subset of a ColumnDataSource.
For example:
days = ['Mon','Tues','Wed']
source = ColumnDataSource({
'x': [1,2,3],
'y': [4,5,2],
'day': days
})
p=figure()
scatter = p.scatter(source=source)
cbg = CheckboxGroup(labels=days, active=[0])
layout = row(cbg, p)
show(layout)
I want to connect the CheckboxGroup to the scatter.
The only way I can think of given the gallery/doc examples is to do something like the below pseudocode:
Add a visibility column to the Source
cbg.js_on_change('active', callback=CustomJS(args=dict(source=source), code="""
selected=active checkboxes
iterate over selected days,
for each day iterate over source.data and toggle each glyph's visibility col
refresh the figure
"""))
I’m sure bokeh has better ways of handling this and I was wondering what the standard/clean way of doing this is (perhaps using a CDSView for each day of the week?)
Note, I did consider looping over the days to render the scatter (so one scatter call for each day of the week), but then I would lose the shared ColumnDataSource.


