【发布时间】:2020-05-19 01:26:01
【问题描述】:
在构建数据表时,Bokeh 中是否有办法去除备用行背景格式?
from datetime import date
from random import randint
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn
from bokeh.io import output_file, show
output_file("data_table.html")
data = dict(idx=[randint(0, 100) for i in range(10)],
values=[randint(0, 100) for i in range(10)])
source = ColumnDataSource(data)
columns = [TableColumn(field="idx", title="Index"),
TableColumn(field="values", title="Values")]
data_table = DataTable(source=source, columns=columns, width=400, height=280)
show(data_table)
创建数据表时,其行以交替的白灰色填充显示,但对于我正在构建的特定数据表,我需要所有行都是白色/透明的,这在 Bokeh 中可以实现吗?
我查过Datatable documentation,但好像没有专门的参数。有background参数,但是尝试了以下选项后不影响生成的数据表:
from bokeh.colors.rgb import RGB
data_table = DataTable(source=source, columns=columns, width=400, height=280, background='red')
data_table = DataTable(source=source, columns=columns, width=400, height=280, background='#000000')
data_table = DataTable(source=source, columns=columns, width=400, height=280,
background=RGB(125, 54, 89))
有趣的是,当我提供一个无效参数(例如,background='000000')时,Bokeh 会返回一个 ValueError,说明可接受与否,其中包括:
ValueError: expected an element of either Enum(...'red',...),
Regex('^#[0-9a-fA-F]{6}$'),
Regex('^rgba\\(((25[0-5]|2[0-4]\\d|1\\d{1,2}|\\d\\d?)\\s*,\\s*?){2}(25[0-5]|2[0-4]\\d|1\\d{1,2}|\\d\\d?)\\s*,\\s*([01]\\.?\\d*?)\\)'),
Regex('^rgb\\(((25[0-5]|2[0-4]\\d|1\\d{1,2}|\\d\\d?)\\s*,\\s*?){2}(25[0-5]|2[0-4]\\d|1\\d{1,2}|\\d\\d?)\\s*?\\)'),
Tuple(Byte(Int, 0, 255), Byte(Int, 0, 255), Byte(Int, 0, 255)),
Tuple(Byte(Int, 0, 255), Byte(Int, 0, 255), Byte(Int, 0, 255), Percent) or RGB, got '000000'
我在这里缺少的数据表是否有启动器?
另外,我知道有一个option 可以用HTMLTemplateFormatter 格式化单元格,但应该避免这种情况,因为我已经为某些列使用了格式选项。
【问题讨论】: