【发布时间】:2018-11-08 19:54:04
【问题描述】:
我在使用bokeh的TapTool和DataTable时遇到了以下问题:
只要单击一个点(使用 TapTool),DataTable 上的选择就不会再在图中显示。
这是 Jupyter Notebook 的最小示例:
from bokeh.plotting import show, output_notebook, figure
from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.layouts import widgetbox, column
from bokeh.models.widgets import DataTable, TableColumn
source = ColumnDataSource(dict(
x=[1, 2, 3, 4, 5],
y=[6, 7, 2, 4, 5],
url=["http://www.stackoverflow.com"]*5))
p = figure(plot_width=400,
plot_height=400,
tools="tap,reset",
)
p.circle(source=source,
x="x",
y="y",
size=20,
color="navy",
alpha=0.5)
columns = [
TableColumn(field="x", title="X-Value"),
TableColumn(field="y", title="Y-Value"),
TableColumn(field="url", title="URL")
]
data_table = DataTable(source=source, columns=columns,
width=400, height=400)
url = "@url"
taptool = p.select(type=TapTool)
taptool.callback = OpenURL(url=url)
output_notebook()
show(column(p, widgetbox(data_table)))
预期行为:DataTable 中的选择会在图中显示,就像单击一个点之前一样。
提前谢谢大家。
【问题讨论】: