[英]Select DropDown unable to change ColumnDataSource using JS Callback
I have tried changing multiple parameters(arguments) but this doesn't work. 我尝试更改多个参数(参数),但这不起作用。
The bokeh version is 1.3.4. 散景版本为1.3.4。
from bokeh.layouts import column
from bokeh.layouts import column
from bokeh.models import CustomJS, ColumnDataSource, Slider, Select
from bokeh.plotting import Figure, output_notebook, show
import numpy as np
a = 20
bokeh_tools = "pan,wheel_zoom"
output_notebook()
plot_2s = ColumnDataSource(data=dict(x=[1, 2, 3], y=[1, 2, 3]))
plot_3s = ColumnDataSource(data=dict(x=[3, 4, 5], y=[1, 2, 3]))
line_source = ColumnDataSource(data=dict(x=[1, 2, 3], y=[1, 2, 3]))
plot_1 = figure(x_axis_type="datetime", plot_width=800, tools=bokeh_tools, title="plot_1")
plot_1.line(x = 'x', y='y', source=plot_2s)
plot_2 = figure(x_axis_type="datetime", plot_width=800, tools=bokeh_tools, title="plot_2")
plot_2.line(x='x', y='y', source=line_source)
select = Select(title="SELECT", options=["val1", "val2"])
column = column(select, plot_2)
show(column)
select.callback = CustomJS(args={"cds2": plot_2s, "cds3": plot_3s, "ls": line_source}, code="""
if(cb_obj.value === "val1"){
ls.data = cds2.data;
}else if(cb_obj.value === "val2"){
ls.data = cds3.data;
}
ls.change.emit();
""")
There are no error message the callback is not implemented 没有错误消息回调未实现
You callback is never executed, because it is never added to the output. 您的回调永远不会执行,因为它永远不会添加到输出中。 As soon as you call show
the HTML output is generated and displayed. 调用show
将立即生成并显示HTML输出。 Anything after that point is effectively a no-op, and does not exist as far as the output is concerned. 在此之后的所有内容实际上都是空操作,并且就输出而言不存在。 Typically show
should be called last. 通常情况下, show
应该被称为last。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.