I have made a stacked bar chart in bokeh with a hover tool and now also wants to add a CheckboxGroup
to the plot. I am however very new to Bokeh, so I am struggeling a bit. I am especially unsure about how to make the update function, I have tried to start it but simply don't understand what it needs to do:
trees_to_plot = [tree_selection.labels[i] for i in
tree_selection.active]
temp = make_dataset(trees_to_plot,
bin_width = 40)
# \TODO: add more code here!
The code for the chart itself looks like this:
p = figure(x_range = districtName,plot_width = 900, plot_height=400,
title='Tree pr. district',toolbar_location= None)
# Stacked bar chart
renderers = p.vbar_stack(stackers=treeName,x='bydelsnavn',source=temp,
width=0.5, color = colornames)
# Add the hover tool
for r in renderers:
tree = r.name
hover = HoverTool(tooltips=[
("%s" % tree, "@{%s}" % tree)
], renderers = [r])
p.add_tools(hover)
p.xaxis.axis_label = 'Copenhagen city cistricts'
p.yaxis.axis_label = 'Tree counts'
# Creat the checkbox selection element
tree_selection = CheckboxGroup(labels=treeName, active = [0,1])
# Link the checkboxes to the information on the graph
tree_selection.on_change('active', update)
# Add to the CheckboxGroup to the figure
controls = WidgetBox(tree_selection)
layout = row(controls,p)
show(layout)
This code will show all the check boxes with the chart but no interaction is obviously happening between the boxes and the chart itself. Can someone point me towards to right direction?
Thanks in advance! :D