Skip to content

Commit 667fc6d

Browse files
Use figure dimensions for other image objects in Previewer (#397)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> - Companion of insightsengineering/teal.modules.general#884 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 295daa8 commit 667fc6d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ Encoding: UTF-8
8484
Language: en-US
8585
LazyData: true
8686
Roxygen: list(markdown = TRUE)
87-
RoxygenNote: 7.3.2
87+
RoxygenNote: 7.3.3

R/toHTML.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ toHTML.default <- function(x, ...) {
7777
#' @keywords internal
7878
.toHTML.gg <- function(x, ...) {
7979
on.exit(unlink(tmpfile))
80+
dims <- resolve_figure_dimensions(x, convert_to_inches = TRUE, dpi = 100)
8081
tmpfile <- tempfile(fileext = ".png")
81-
ggplot2::ggsave(tmpfile, plot = x, width = 5, height = 4, dpi = 100)
82+
ggplot2::ggsave(tmpfile, plot = x, width = dims$width, height = dims$height, dpi = 100)
8283
shiny::tags$img(src = knitr::image_uri(tmpfile))
8384
}
8485

8586
#' @method .toHTML grob
8687
#' @keywords internal
8788
.toHTML.grob <- function(x, ...) {
8889
on.exit(unlink(tmpfile))
90+
dims <- resolve_figure_dimensions(x)
8991
tmpfile <- tempfile(fileext = ".png")
90-
grDevices::png(filename = tmpfile)
92+
grDevices::png(filename = tmpfile, width = dims$width, height = dims$height)
9193
grid::grid.newpage()
9294
grid::grid.draw(x)
9395
grDevices::dev.off()

man/ReportCard.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/Reporter.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)