[英]Bokeh table widget with category names in the first column in each row and data in the next column
I want to create a Bokeh table widget with category names in the first column in each row and data in the second other column. 我想创建一个散景表窗口小部件,其类别名称在每行的第一列中,数据在第二列中。
Is there a way to achieve this. 有没有办法实现这一目标。
Thanks. 谢谢。
You can add everything you want to your table, as long as it's in your ColumnDataSource. 您可以将所需的所有内容添加到表中,只要它们在ColumnDataSource中即可。
More information about tables can be found here . 有关表的更多信息,请参见此处 。
from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.palettes import Spectral6
from bokeh.plotting import figure
from bokeh.transform import factor_cmap
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.layouts import row
output_file("colormapped_bars.html")
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 4, 2, 4, 6]
source = ColumnDataSource(data=dict(fruits=fruits, counts=counts))
p = figure(x_range=fruits, plot_height=250, toolbar_location=None, title="Fruit Counts")
p.vbar(x='fruits', top='counts', width=0.9, source=source, legend="fruits",
line_color='white', fill_color=factor_cmap('fruits', palette=Spectral6, factors=fruits))
columns = [
TableColumn(field="fruits", title="Fruits"),
TableColumn(field="counts", title="Counts")
]
data_table = DataTable(source=source, columns=columns, width=400, height=280, index_position=None)
p.xgrid.grid_line_color = None
p.y_range.start = 0
p.y_range.end = 9
p.legend.orientation = "horizontal"
p.legend.location = "top_center"
show(row(p, data_table))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.