@@ -532,6 +532,12 @@ Scale <- ggproto("Scale", NULL,
532
532
)
533
533
},
534
534
535
+ updatable_params = c(
536
+ " aesthetics" , " scale_name" , " palette" , " name" , " breaks" , " labels" ,
537
+ " limits" , " expand" , " na.value" , " guide" , " position" , " call" ,
538
+ " super"
539
+ ),
540
+
535
541
update = function (self , params ) {
536
542
check_update_params(self , params )
537
543
inject(self $ new(!!! params ))
@@ -560,16 +566,7 @@ check_breaks_labels <- function(breaks, labels, call = NULL) {
560
566
}
561
567
562
568
check_update_params <- function (scale , params ) {
563
- if (inherits(scale , " ScaleContinuous" )) {
564
- args <- fn_fmls_names(continuous_scale )
565
- } else if (inherits(scale , " ScaleDiscrete" )) {
566
- args <- fn_fmls_names(discrete_scale )
567
- } else if (inherits(scale , " ScaleBinned" )) {
568
- args <- fn_fmls_names(binned_scale )
569
- } else {
570
- # We don't know what valid parameters are of custom scale types
571
- return (invisible (NULL ))
572
- }
569
+ args <- scale $ updatable_params
573
570
extra <- setdiff(names(params ), args )
574
571
if (length(extra ) == 0 ) {
575
572
return (invisible (NULL ))
@@ -902,6 +899,11 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
902
899
)
903
900
},
904
901
902
+ updatable_params = c(
903
+ Scale $ updatable_params ,
904
+ " minor_breaks" , " n.breaks" , " rescaler" , " oob" , " transform"
905
+ ),
906
+
905
907
update = function (self , params ) {
906
908
check_update_params(self , params )
907
909
# We may need to update limits when previously transformed and
@@ -1145,6 +1147,11 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
1145
1147
)
1146
1148
},
1147
1149
1150
+ updatable_params = c(
1151
+ Scale $ updatable_params ,
1152
+ " minor_breaks" , " na.translate" , " drop"
1153
+ ),
1154
+
1148
1155
new = function (self , aesthetics = NULL , palette = NULL , limits = NULL , call = caller_call(),
1149
1156
range = DiscreteRange $ new(),
1150
1157
... , super = NULL ) {
@@ -1416,6 +1423,12 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1416
1423
major_source = major , minor_source = NULL )
1417
1424
},
1418
1425
1426
+ updatable_params = c(
1427
+ Scale $ updatable_params ,
1428
+ " rescaler" , " oob" , " n.breaks" , " nice.breaks" ,
1429
+ " right" , " transform" , " show.limits"
1430
+ ),
1431
+
1419
1432
new = function (self , ... , super = NULL ) {
1420
1433
ggproto_parent(ScaleContinuous , self )$ new(... , super = super %|| % self )
1421
1434
}
0 commit comments