Bokeh:unexpected attribute ‘callback‘ to CheckboxGroup, similar attributes are js_event_callbacks(代码

Posted Circle-C

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bokeh:unexpected attribute ‘callback‘ to CheckboxGroup, similar attributes are js_event_callbacks(代码相关的知识,希望对你有一定的参考价值。

使用Bokeh绘图出现如下报错

AttributeError: unexpected attribute 'callback' to CheckboxGroup, similar attributes are js_event_callbacks

 解决:

checkbox.callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox), code="""
l0.visible = 0 in checkbox.active;
l1.visible = 1 in checkbox.active;
l2.visible = 2 in checkbox.active;
""")

改为

callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox), code="""
l0.visible = 0 in checkbox.active;
l1.visible = 1 in checkbox.active;
l2.visible = 2 in checkbox.active;
""")
checkbox.js_on_change('active', callback)  # js_on_change的第一个参数为需要改变的参数

 

以上是关于Bokeh:unexpected attribute ‘callback‘ to CheckboxGroup, similar attributes are js_event_callbacks(代码的主要内容,如果未能解决你的问题,请参考以下文章

__attribute__((constructor))和__attribute__((destructor))

glsl attributes变量怎么用

Rails:#update_attribute 与 #update_attributes

[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]:约束

理解Attribute

Attribute