Skip to content

Commit 7ff38c9

Browse files
committed
ensure device size reflects specified size in RStudio, fixes #1190
1 parent 0beb525 commit 7ff38c9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

R/ggplotly.R

+3-7
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ gg2list <- function(p, width = NULL, height = NULL,
171171
# To avoid undesirable side effects, we may need to open a
172172
# non-interactive device and close it on exit...
173173
# https://github.com/att/rcloud.htmlwidgets/issues/2
174-
175-
# Note that we never have to open a non-interactive device
176-
# in RStudio since it ships with one. Plus, calling dev.size()
177-
# adds it to dev.list() & should ensure grid can query the correct device size
178-
rStudioDevSize <- if (is_rstudio()) grDevices::dev.size("px")
179-
180174
if (is.null(grDevices::dev.list())) {
181175
dev_fun <- if (system.file(package = "Cairo") != "") {
182176
Cairo::Cairo
@@ -194,7 +188,9 @@ gg2list <- function(p, width = NULL, height = NULL,
194188
call. = FALSE
195189
)
196190
}
197-
dev_fun(file = tempfile(), width = width %||% 640, height = height %||% 480)
191+
width <- width %||% grDevices::dev.size("px")[1] %||% 640
192+
height <- height %||% grDevices::dev.size("px")[2] %||% 480
193+
dev_fun(file = tempfile(), width = width, height = height)
198194
on.exit(grDevices::dev.off(), add = TRUE)
199195
}
200196

0 commit comments

Comments
 (0)