PgBiel / typst-tablex

More powerful and customizable tables in Typst
MIT License
370 stars 12 forks source link

Cell fill by calculation #30

Closed ondohotola closed 1 year ago

ondohotola commented 1 year ago

Is it possible (or even feasible) to have the cell background filled depending on the value of the cell's content?

for example, something like this pseudo-code

[...]
if the cell content is a number then
   if the cell value is < 0 then 
      fill red
   else  the cell value is > 0 then 
      fill green
[...]

default would then be 0 and white.

PgBiel commented 1 year ago

Yeah, you can adapt the first example from the README:

https://github.com/PgBiel/typst-tablex/blob/b36a5f3cf9143696d3333c0310232d25f1b89dd6/README.md?plain=1#L54-L72

You'll just have to cell.fill = ... instead of cell.content = { set text(...) }.

PgBiel commented 1 year ago

Closing this as solved; feel free to reply if you'd like further explanation.