Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color_tiles() ignores colDefs na= argument #45

Open
eastclintw00d opened this issue Nov 9, 2022 · 1 comment
Open

color_tiles() ignores colDefs na= argument #45

eastclintw00d opened this issue Nov 9, 2022 · 1 comment

Comments

@eastclintw00d
Copy link

I wanted to use color_tiles and came across the issue that it ignores the na= argument from colDef and prints out the missing values as NA.

library(reactable)
library(reactablefmtr)
library(dplyr)

tile_column <- function(x) {
  colDef(
    show = TRUE, 
    na = "",
    cell = color_tiles(
      x,
      colors = c("red", "orange", "yellow", "limegreen", "green"),
      number_fmt = scales::percent_format(scale = 1, accuracy = .1, decimal.mark = ",", big.mark = "."),
      box_shadow = TRUE,
    )
  )
}

data <- tibble(
  col1 = c(1, 4, 2, 5, NA_integer_, 2),
  col2 = c(2, 1, 2, NA_real_, NA_real_, 2),
)

data |> reactable() ## works -> no NAs are printed

data %>%
  reactable(
    columns = list(
      col1 = tile_column(.),
      col2 = tile_column(.)
    )
  ) ## does not work

Can you please have a look and maybe fix this?

@eastclintw00d eastclintw00d changed the title color_tiles() ignores colDefs 'na=' argument color_tiles() ignores colDefs na= argument Nov 9, 2022
@eastclintw00d
Copy link
Author

eastclintw00d commented Nov 9, 2022

Note that in my real application I still want to be able to color a tile by another column although its label is NA. The tile should not vanish entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant