[英]Vertical alignment of text within Bokeh DataTable
I have the following code that produces a datatable in Bokeh:我有以下代码在 Bokeh 中生成数据表:
from bokeh.models import DataTable, TableColumn, HTMLTemplateFormatter
data = {'A': ['A1', 'A2', 'A3', 'A4'],
'B': ['B1', 'B2', 'B3', 'B4'],
'C': ['C1', 'C2', 'C3', 'C4'],
'D': ['D1', 'D2', 'D3', 'D4']}
source = ColumnDataSource(data)
table = DataTable(height=500,
width=500,
source=source,
row_height=50,
columns=[TableColumn(field=col, title=col) for col in data.keys()])
# Align text horisontally (need to do it vertically as well)
for col in table.columns:
col.formatter.text_align = 'center'
show(table)
This produces the following table:这将产生下表:
I would like to align the text vertically in the middle of the cells.我想在单元格中间垂直对齐文本。 From what I've seen online I could use
HTMLTemplateFormatter
to achieve this, but I'm not quite sure how.从我在网上看到的情况来看,我可以使用
HTMLTemplateFormatter
来实现这一点,但我不太确定如何。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.