gt
gt copied to clipboard
Autocoloroptions
I have added light and dark autocolor_text color options. Often, tables are embedded in a context and in there "black" is not black, but another very dark color and analogously for white. Being able to design the tables in harmony is central.
The current implementation follows the previous design of {gt}, particularly data_color(), but/thus it is unattractive in that if autocolor = FALSE, now allready 3 arguments are irrelevant.
- [ x] I understand and agree to the Code of Conduct.
- [x] I have listed any major changes in the NEWS.
- [x ] I have added
testthatunit tests totests/testthatfor any new functionality.
Additionally, I fixed a constant in the calculation of relative luminance WCAG (according to documentation).
Hi @rich-iannone and @olivroy since it has been a while since I opened this pull request, and I would still like to be able to use this feature in various situations (i.e., tables I create), I would like to ask what you think about it!?
Here's an example, not because it is particularly aesthetically pleasing, but I think it serves the purpose of clearly pointing out differences. Run it with and without autocolor_light = "#FFE8D1".
exibble |>
gt() |>
data_color(
columns = c(fctr, datetime, group),
method = "factor",
rows = c(2, 4:6, 8),
palette = "#725F0B",
na_color = "#B6D7C7",
autocolor_light = "#FFE8D1"
) |>
data_color(
columns = c(date, currency),
palette = "#6E6684",
na_color = "#B6D7C7",
autocolor_light = "#FFE8D1"
) |>
tab_options(
table.background.color = "#004249",
table.font.color.light = "#FFE8D1"
)