Is it possible to do conditional formatting on an org-table?

49 views Asked by At

Here is an example of a table to format,

  • the first row represents how often a task is done per year,
  • the first column represents how long a task takes in seconds
|-------+------------+-----------+----------+---------+---------+-------|
|       |      18250 |      1825 |      365 |      52 |      12 |     1 |
|-------+------------+-----------+----------+---------+---------+-------|
|     1 |      18250 |      1825 |      365 |      52 |      12 |     1 |
|     5 |      91250 |      9125 |     1825 |     260 |      60 |     5 |
|    30 |     547500 |     54750 |    10950 |    1560 |     360 |    30 |
|    60 |    1095000 |    109500 |    21900 |    3120 |     720 |    60 |
|   300 |    5475000 |    547500 |   109500 |   15600 |    3600 |   300 |
|  1800 |   32850000 |   3285000 |   657000 |   93600 |   21600 |  1800 |
|  3600 |   65700000 |   6570000 |  1314000 |  187200 |   43200 |  3600 |
| 21600 |  394200000 |  39420000 |  7884000 | 1123200 |  259200 | 21600 |
| 86400 | 1576800000 | 157680000 | 31536000 | 4492800 | 1036800 | 86400 |
|-------+------------+-----------+----------+---------+---------+-------|
#+TBLFM: $2=$1*@1$2::$3=$1*@1$3::$4=$1*@1$4::$5=$1*@1$5::$6=$1*@1$6::$7=$1*@1$7

Is it possible to change the cell display while keeping the values?

Here are some examples of displays:

|-------+-------+---------|
| Cell  | Value | Display |
|-------+-------+---------|
| @1$4  |   365 | Daily   |
| @1$7  |     1 | Yearly  |
| @3$6  |    60 | 1 m     |
| @6$6  |  3600 | 1 h     |
| @10$1 | 86400 | 1 d     |
|-------+-------+---------|

Here is a complete example from https://xkcd.com (where values are multiplied by 5):

XKCD chart

Ideally, I would like the display to be generated according to some rules (e.g. for all rows below row 1, if 3600 < x > 59, divide by 60 and add " m"), and to show a heat map.

I don't necessarily need the formatting to be done by org-mode. The table will be exported to HTML, so ideally, the formatting would be done through HTML export and JS code (using some cdn library).

0

There are 0 answers