免责声明:我对Bokeh的绘图工作并不陌生,可能对一般编程不好(我只是喜欢编写代码和编写方便的脚本以供工作使用。)
如果我将以下代码示例作为bokeh服务器应用程序运行,则在数据表上选择一行将突出显示绘图上的对应字形;但是,使用TapTool在图上选择一个字形不会突出显示DataTable上的相应行,可以这样做。
from bokeh.plotting import figure, curdoc, ColumnDataSource
from bokeh.models import HoverTool, ResetTool, TapTool
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.layouts import gridplot
data = {'a': [1,2,3,4,5,6,7,8,9,10],
'b': [11,12,13,14,15,16,17,18,19,20]}
source = ColumnDataSource(data)
tools=[HoverTool(), TapTool(), ResetTool()]
columns = [TableColumn(field='a', title='A'),
TableColumn(field='b', title='B')]
p1 = figure(plot_width=400,
plot_height=400,
title='Example',
x_axis_label='Example X',
y_axis_label='Example Y',
tools=tools)
p1.circle_cross(x='a',
y='b',
source=source)
t1 = DataTable(columns=columns,
editable=False,
height=200,
width=400,
fit_columns=True,
source=source)
layout = gridplot([[p1],[t1]])
curdoc().add_root(layout)
答案 0 :(得分:0)
尝试将scroll_to_selection= True, selectable = True
属性添加到您的DataTable
中
t1 = DataTable(columns=columns,
editable=False,
height=200,
width=400,
fit_columns=True,
source=source,
scroll_to_selection= True, selectable = True)