Skip to content

Commit

Permalink
Make ggplot2 a soft dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Mar 31, 2023
1 parent a0ff24e commit 1b39ed1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Imports:
commonmark (>= 1.8.1),
dplyr (>= 1.1.0),
fs (>= 1.6.1),
ggplot2 (>= 3.4.1),
glue (>= 1.6.2),
htmltools (>= 0.5.4),
htmlwidgets (>= 1.6.1),
Expand All @@ -57,6 +56,7 @@ Imports:
Suggests:
covr,
digest (>= 0.6.31),
ggplot2,
knitr,
lubridate,
paletteer,
Expand Down
8 changes: 8 additions & 0 deletions R/image.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ ggplot_image <- function(
aspect_ratio = 1.0
) {

if (!requireNamespace("ggplot2", quietly = TRUE)) {

cli::cli_abort(c(
"Using the `ggplot_image()` function requires the `ggplot2` package.",
"*" = "It can be installed with `install.packages(\"ggplot2\")`."
))
}

if (is.numeric(height)) {
height <- paste0(height, "px")
}
Expand Down

0 comments on commit 1b39ed1

Please sign in to comment.