I have the following code that produces a datatable in 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.