Bokeh演示展示了如何向滑块按钮添加回调 - http://bokeh.pydata.org/en/0.11.1/docs/user_guide/interaction.html#customjs-with-a-python-function
我正在尝试为单选按钮组创建类似的回调 -
radio_button_group = RadioButtonGroup(labels=["literacy", "economy", "health","household"], active=0,callback=CustomJS.from_py_func(callback) )
但上面的代码给出了错误 -
AttributeError: unexpected attribute 'callback' to RadioButtonGroup, possible attributes are active, disabled, labels, name, tags or type
Bokeh是否支持来自单选按钮组的回调,或者只能从滑块按钮进行回调,如文档中所示?
答案 0 :(得分:1)
不同的小部件具有包含所选/突出显示的值的不同属性。对于RadioButtonGroup
active
,slider
为value
您必须相应地更改callback
功能
def callback(source=source):
data = source.get('data')
f = cb_obj.get('active') # instead of 'value'
x, y = data['x'], data['y']
for i in range(len(x)):
y[i] = Math.pow(x[i], f)
source.trigger('change')