下面的脚本(来自this SO answer)生成一个simpleapp Bokeh图。在
如何将输出保存到独立的html文件?import bokeh.plotting as bk
from bokeh.models import ColumnDataSource, Plot
from bokeh.models.widgets import Select, AppVBox
from bokeh.simpleapp import simpleapp
data = {"a": {"x": [1,2,3], "y": [1,2,3]},
"b": {"x": [3,2,1], "y": [1,2,3]},
"c": {"x": [2,2,2], "y": [1,2,3]},}
options = ["a", "b", "c"]
select1 = Select(name = 'ticker1', value = options[0], options = options)
@simpleapp(select1)
def test_layout(ticker1):
p = bk.figure(title = "layout test")
chart_data = data[ticker1]
df = ColumnDataSource(data = chart_data)
p.circle(x = chart_data["x"], y = chart_data["y"])
return {'plot': p}
@test_layout.layout
def layout(app):
return AppVBox(app=app, children=['ticker1', 'plot'])
test_layout.route("/bokeh/layout/")
我试图改变layout(app)来使用file_html。这将生成初始绘图,但组合框不起作用。我认为file_html只适用于单个绘图对象,而不是我正在使用的simpleapp之类的对象。在
^{pr2}$