Skip to content

Commit 900a61a

Browse files
committed
Merge scale calls
1 parent a7b43b3 commit 900a61a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

R/scale-.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,25 @@ Scale <- ggproto("Scale", NULL,
572572
return()
573573
},
574574

575-
update_params = function(self, params, default = FALSE) {
575+
update_params = function(self, params, default = FALSE, call = NULL) {
576576

577577
fields <- intersect(self$fields, names(params))
578578
extra <- setdiff(names(params), fields)
579579

580580
if (length(extra) > 0) {
581581
cli::cli_warn(
582-
"Ignoring unknown scale parameter{?s}: {.and {.field {extra}}}."
582+
"Ignoring unknown scale parameter{?s}: {.and {.field {extra}}}.",
583+
call = call
583584
)
584585
}
585586

587+
if (is.null(self$call)) {
588+
self$call <- call
589+
} else if (!is.null(call)) {
590+
self$call <- call("+", self$call, call)
591+
}
592+
call <- self$call
593+
586594
if (!default) {
587595
# Don't update fields that were already defined in non-default scale
588596
fields <- setdiff(fields, call_args_names(self$call))

R/scale-partial.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ ScalePartial <- ggproto(
4040

4141
update_params = function(self, params, default = FALSE, call = self$call) {
4242
self$params <- defaults(params, self$params)
43+
if (is.null(self$call)) {
44+
self$call <- call
45+
} else if (!is.null(call)) {
46+
self$call <- call("+", self$call, call)
47+
}
48+
return()
4349
},
4450

4551
clone = function(self) {

0 commit comments

Comments
 (0)