Skip to content

Commit 348c82f

Browse files
committed
More robust shim for new setup_layer() ggplot2:::Layer method
See also #1481 and tidyverse/ggplot2#2875
1 parent 925f7af commit 348c82f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

R/ggplotly.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ gg2list <- function(p, width = NULL, height = NULL,
238238

239239
# ggplot2 3.1.0.9000 introduced a Layer method named setup_layer()
240240
# currently, LayerSf is the only core-ggplot2 Layer that makes use
241-
# of it https://github.com/tidyverse/ggplot2/pull/2875
241+
# of it https://github.com/tidyverse/ggplot2/pull/2875#issuecomment-438708426
242242
data <- layer_data
243243
if (packageVersion("ggplot2") > "3.1.0") {
244-
data <- by_layer(function(l, d) l$setup_layer(d, plot))
244+
data <- by_layer(function(l, d) if (is.function(l$setup_layer)) l$setup_layer(d, plot) else d)
245245
}
246246

247247
# Initialise panels, add extra data for margins & missing facetting

0 commit comments

Comments
 (0)