【发布时间】:2021-10-17 00:06:44
【问题描述】:
我想知道是否可以仅将颜色应用于 DataTable 单元格的部分文本
目前我有这张桌子:
那个表的代码是这个:
DataTable(
id="comparison_table",
columns=[{"name": "Version", "id": "Version"},
{"name": "Nº entities", "id": "Nº entities"},
{"name": "Nº types", "id": "Nº types"}
],
style_header=
{
'fontWeight': 'bold',
'font-size': '1.1067708333333333vw',
'text-align': 'center'
},
style_cell={'text-align': 'left'},
data=[
{
"Version": value1,
"Nº entities": entities_version1,
"Nº types": types_version1
},
{
"Version": value2,
"Nº entities": entities_version2 + entity_growth_text ,
"Nº types": types_version2 + type_growth_text
}
],
fill_width=False,
style_table={
'overflowY': 'scroll', 'height': '8.138020833333334vw', 'width': '97.65625vw', 'margin-left': '0.6510416666666666vw'
}
)
]
)
我只想为表格第二行中的括号着色。在这种情况下,entity_growth_text 和 type_growth_text 变量。
如果括号内的数字以+开头,颜色应该是green
如果括号内的数字以-开头,则颜色应为red
希望你能帮我解决这个问题。提前致谢。
【问题讨论】:
-
所以只有括号应该有颜色,而不是里面有什么?
-
括号和数字都
标签: python plotly plotly-dash dashboard plotly-python