I'm trying to create a Bokeh plot which allows me toggle the visibility of lines in the figure by clicking checkboxes.
I started trying to use a js callback to a checkbox group, but found unfortunately that js callbacks have not actually been implemented for the checkbox group.
Could anyone suggest another way to toggle line visibility in a bokeh plot. I'm guessing that modifying the alpha properties of the lines is the way to go.
Here is some simple sample code for creating my plot:
from bokeh.plotting import figure, show, output_notebook
from bokeh.io import vform
from bokeh.models.widgets import CheckboxGroup
output_notebook()
x = [1, 2, 3, 4, 5]
y1 = [3, 5, 6, 4, 5]
y2 = [2, 4, 7, 6, 5]
p = figure()
line1 = p.line(x, y1, alpha=1, color='blue', legend='blue line')
line2 = p.line(x, y2, alpha=1, color='red', legend='red line')
cbgroup = CheckboxGroup(labels=["toggle blue line","toggle red line"], active=[0,1])
show(vform(p,cbgroup))