Skip to content

Commit 37b79e9

Browse files
committed
support the new Layer method setup_layer()
1 parent 18e66d2 commit 37b79e9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/ggplotly.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,18 @@ gg2list <- function(p, width = NULL, height = NULL,
236236
out
237237
}
238238

239+
# ggplot2 3.1.0.9000 introduced a Layer method named setup_layer()
240+
# currently, LayerSf is the only core-ggplot2 Layer that makes use
241+
# of it https://github.com/tidyverse/ggplot2/pull/2875
242+
data <- layer_data
243+
if (packageVersion("ggplot2") > "3.1.0") {
244+
data <- by_layer(function(l, d) l$setup_layer(d, plot))
245+
}
246+
239247
# Initialise panels, add extra data for margins & missing facetting
240248
# variables, and add on a PANEL variable to data
241249
layout <- ggfun("create_layout")(plot$facet, plot$coordinates)
242-
data <- layout$setup(layer_data, plot$data, plot$plot_env)
250+
data <- layout$setup(data, plot$data, plot$plot_env)
243251

244252
# save the domain of the group for display in tooltips
245253
groupDomains <- Map(function(x, y) {

0 commit comments

Comments
 (0)