gt icon indicating copy to clipboard operation
gt copied to clipboard

Autocoloroptions

Open xx02al opened this issue 11 months ago • 3 comments

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.

Additionally, I fixed a constant in the calculation of relative luminance WCAG (according to documentation).

xx02al avatar Dec 02 '24 18:12 xx02al

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 06 '24 17:12 CLAassistant

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!?

xx02al avatar Feb 07 '25 11:02 xx02al

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"
  )

xx02al avatar Feb 25 '25 14:02 xx02al