Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/coord-.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Coord <- ggproto("Coord",
panel_params
},

train_panel_guides = function(self, panel_params, layers, params = list()) {
train_panel_guides = function(self, panel_params, layers, params = list(), data = NULL) {

aesthetics <- c("x", "y", "x.sec", "y.sec")

Expand All @@ -163,8 +163,8 @@ Coord <- ggproto("Coord",
guide_params[!empty] <- Map(
function(guide, guide_param, scale) {
guide_param <- guide$train(guide_param, scale)
guide_param <- guide$get_layer_key(guide_param, layers, data)
guide_param <- guide$transform(guide_param, self, panel_params)
guide_param <- guide$get_layer_key(guide_param, layers)
guide_param
},
guide = guides[!empty],
Expand Down
2 changes: 1 addition & 1 deletion R/coord-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ CoordMap <- ggproto("CoordMap", Coord,
panel_params
},

train_panel_guides = function(self, panel_params, layers, params = list()) {
train_panel_guides = function(self, panel_params, layers, params = list(), data = NULL) {
panel_params
},

Expand Down
2 changes: 1 addition & 1 deletion R/coord-polar.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ CoordPolar <- ggproto("CoordPolar", Coord,
panel_params
},

train_panel_guides = function(self, panel_params, layers, default_mapping, params = list()) {
train_panel_guides = function(self, panel_params, ...) {
panel_params
},

Expand Down
2 changes: 1 addition & 1 deletion R/coord-radial.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
panel_params
},

train_panel_guides = function(self, panel_params, layers, params = list()) {
train_panel_guides = function(self, panel_params, layers, params = list(), data = NULL) {

aesthetics <- c("r", "theta", "r.sec", "theta.sec")
aesthetics <- intersect(aesthetics, names(panel_params$guides$aesthetics))
Expand Down
2 changes: 1 addition & 1 deletion R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
panel_params
},

train_panel_guides = function(self, panel_params, layers, params = list()) {
train_panel_guides = function(self, panel_params, layers, params = list(), data = NULL) {
# The guide positions are already in the target CRS, so we mask the default
# CRS to prevent a double transformation.
panel_params$guides <- ggproto_parent(Coord, self)$train_panel_guides(
Expand Down
24 changes: 11 additions & 13 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,26 +219,24 @@ Layout <- ggproto("Layout", NULL,
invisible()
},

setup_panel_guides = function(self, guides, layers) {

# Like in `setup_panel_params`, we only need to setup guides for unique
# combinations of x/y scales.
index <- vec_unique_loc(self$layout$COORD)
order <- vec_match(self$layout$COORD, self$layout$COORD[index])
setup_panel_guides = function(self, guides, layers, data = NULL) {

self$panel_params <- lapply(
self$panel_params[index],
self$panel_params,
self$coord$setup_panel_guides,
guides,
self$coord_params
)

self$panel_params <- lapply(
self$panel_params,
self$coord$train_panel_guides,
layers,
self$coord_params
)[order]
self$panel_params <- Map(
function(params, data) {
self$coord$train_panel_guides(params, layers, self$coord_params, data = data)
},
params = self$panel_params,
data = lapply(levels(self$layout$PANEL), function(i) {
lapply(data, function(x) vec_slice(x, x$PANEL == i))
})
)

invisible()
},
Expand Down
2 changes: 1 addition & 1 deletion R/plot-build.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ggplot_build.ggplot <- function(plot) {
data <- layout$map_position(data)

# Hand off position guides to layout
layout$setup_panel_guides(plot$guides, plot$layers)
layout$setup_panel_guides(plot$guides, plot$layers, data = data)

# Complete the plot's theme
plot$theme <- plot_theme(plot)
Expand Down
Loading