jeudi 18 mars 2021

Bokeh Checkbox callback with CustomJS

:)

I have trouble to using and understanding bokeh for buttons with callback. I try to change the number of stackers in a figure "bar_stack" with Checkbox button :

p = figure(x_range=Index,plot_height=250,toolbar_location=None, tools="")
pbar = p.vbar_stack(stackers=LABEL, x='index', width=0.9,alpha=1, color=C, source=csource,legend_label=LABEL)

with LABEL a list of column names in the source. I want to change this list with checkbox. I try this,but it didn't work :

cb_cselect = CustomJS(args=dict(cir=pbar, csource=csource), code="""
 pbar.glyph.stackers=cb_obj.active
 csource.change.emit(); """)


checkbox_group = CheckboxGroup(labels=LABEL,active=[0,1])
checkbox_group.js_on_click( cb_cselect)

I think I'm misunderstanding "cb_obj.active".

This means, for example, making some dates invisible on this image, with buttons. enter image description here

Sorry I am surely not very clear, but do you have any ideas?

Thank you very much :),




Aucun commentaire:

Enregistrer un commentaire