我希望您能够更改Bokeh图表的标题,以下是我尝试过的最简代码示例。问题在于如何进行回调。"Original Answer"翻译成"最初的回答"。
我没有收到任何错误信息,但当我在TextInput字段中输入新标题时,没有任何反应。有什么想法吗?
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.models import CustomJS, Button
fig = figure(title='title')
fig.line(x=[1,2,3], y=[1,2,3])
callback = CustomJS(args={'title':fig.title}, code="""title.text = text_input.get('value');
""")
text_input = TextInput(title="Add graph title", value='', callback=callback)
widgets_layout = column(text_input)
figures_layout = row(fig)
page_layout = row(widgets_layout, fig)
script, div = components(page_layout)
return render_to_response('fig.html', {'script': script, 'div': div})
我没有收到任何错误信息,但当我在TextInput字段中输入新标题时,没有任何反应。有什么想法吗?
有什么建议吗?
title
字符串传递给figure
实际上是为了向绘图添加一个Title
注释的快捷方式,这才是实际必须链接的内容。 - bigreddot