简体   繁体   English

选择DropDown无法使用JS回调更改ColumnDataSource

[英]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.

相关问题 Bokeh - 在下拉菜单中更改时无法更新ColumnDataSource - Bokeh - unable to update ColumnDataSource upon change in dropdown menu 在MapDataSource更改绘图时触发JavaScript回调 - Trigger a JavaScript callback upon ColumnDataSource change in a plot 将.filter() 应用于 Bokeh JS 回调中的 ColumnDataSource - Applying .filter() to ColumnDataSource in Bokeh JS Callback 散景Python; 使用ColumnDataSource上的Callback来更改Stacked Bar Chart with Select Widget - Bokeh Python; Use Callback on ColumnDataSource to change Stacked Bar Chart with Select Widget 散景:使用TextInput小部件选择ColumnDataSource的行 - Bokeh: Select row of ColumnDataSource using TextInput widget 散景 Python:Select 下拉列表正在更新 ColumnDataSource 但不更新图表 - Bokeh Python: Select dropdown is updating ColumnDataSource but not updating the graph 无法在python硒中选择JS下拉选项 - Unable to select JS dropdown option in python selenium 无法使用 selenium python 选择下拉值 - Unable to select dropdown value using selenium python Bokeh CustomJS 回调不适用于 ColumnDataSource 和 RadioButtonGroup - Bokeh CustomJS callback is not working for ColumnDataSource and RadioButtonGroup 让Bokeh回调更新列表而不是ColumnDataSource吗? - Have Bokeh Callback update a list instead of a ColumnDataSource?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM