Skip to content

Add setup_params method to Geom #3509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2019
Merged
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 (development version)

* `Geom` now gains a `setup_params()` method in line with the other ggproto
classes (@thomasp85, #3509)

* `element_text()` now issues a warning when vectorized arguments are provided, as in
`colour = c("red", "green", "blue")`. Such use is discouraged and not officially supported
(@clauswilke, #3492).
Expand Down
2 changes: 2 additions & 0 deletions R/geom-.r
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ Geom <- ggproto("Geom",
stop("Not implemented")
},

setup_params = function(data, params) params,

setup_data = function(data, params) data,

# Combine data with defaults and set aesthetics from parameters
Expand Down
4 changes: 2 additions & 2 deletions R/layer.r
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ Layer <- ggproto("Layer", NULL,
c(names(data), names(self$aes_params)),
snake_class(self$geom)
)

self$geom$setup_data(data, c(self$geom_params, self$aes_params))
self$geom_params <- self$geom$setup_params(data, c(self$geom_params, self$aes_params))
self$geom$setup_data(data, self$geom_params)
},

compute_position = function(self, data, layout) {
Expand Down