I was wondering if it is possible to apply color only to a part of the text of a DataTable cell
At the moment I have this table:
The code of that table is this one:
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'
}
)
]
)
I want to color only the brackets that are found in the second row of the table. In this case, entity_growth_text
and type_growth_text
variables.
If the number inside the brackets starts with a +
, color should be green
Else if the number inside the brackets starts with a -
, color should be red
Hope you can help me with this. Thanks in advance.