Closed maxbolger closed 2 years ago
Figured out the problem - appears that phantom_js()
which powers webshot
wasn't handling the CSS. I switched internal dependency to webshot2
for gtsave_extra()
. You'll likely need to install it from Github via:
remotes::install_github("rstudio/webshot2")
You'll notice that gtsave_extra()
requires a bit more effort on your part than gtsave()
- this is intentional as it gives full control over the "screenshot" and doesn't have a selector down to the "table" element. This allows for some very creative things, especially when combining tables.
You'll likely want to set the vwidth
and vheight
arguments to something besides the defaults.
library(gt)
library(gtExtras)
test_data <- dplyr::tibble(x = letters[1:10],
y = seq(100, 10, by = -10),
z = seq(10, 100, by = 10))
color_box_tab <- test_data %>%
gt() %>%
gt_color_box(columns = y, domain = 0:100, palette = "ggsci::blue_material") %>%
gt_color_box(columns = z, domain = 0:100,
palette = c("purple", "lightgrey", "green"))
color_box_tab %>%
gtsave_extra("test.png")
For some reason it is still not working for me even after installing webshot2
from GitHub (webshot2_0.0.0.9000
, gtExtras_0.2.3
, gt_0.4.0
). I also just noticed the font isn't even the same after saving. Using vwidth
and vheight
work as intended, though.
Looks like you're on gtExtras_0.2.3
Try update to latest release of gtExtras_0.2.6
remotes::install_github("jthomasmock/gtExtras")
Having an issue when using
gt_color_box()
where the surrounding border box is showing up in my R session output but absent when the table is downloaded usinggtsave()
orgtsave_extra()
(the color swatch to the left of the number in each row is present in both my R session output and the downloaded image, though).