@@ -745,7 +745,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
745
745
if (zero_range(as.numeric(transformation $ transform(limits )))) {
746
746
breaks <- limits [1 ]
747
747
} else if (is.waive(self $ breaks )) {
748
- if (! is.null(self $ n.breaks ) && trans_support_nbreaks (transformation )) {
748
+ if (! is.null(self $ n.breaks ) && support_nbreaks (transformation $ breaks )) {
749
749
breaks <- transformation $ breaks(limits , self $ n.breaks )
750
750
} else {
751
751
if (! is.null(self $ n.breaks )) {
@@ -1237,7 +1237,7 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1237
1237
)
1238
1238
} else if (is.waive(self $ breaks )) {
1239
1239
if (self $ nice.breaks ) {
1240
- if (! is.null(self $ n.breaks ) && trans_support_nbreaks (transformation )) {
1240
+ if (! is.null(self $ n.breaks ) && support_nbreaks (transformation $ breaks )) {
1241
1241
breaks <- transformation $ breaks(limits , n = self $ n.breaks )
1242
1242
} else {
1243
1243
if (! is.null(self $ n.breaks )) {
@@ -1399,8 +1399,11 @@ check_transformation <- function(x, transformed, name, arg = NULL, call = NULL)
1399
1399
cli :: cli_warn(msg , call = call )
1400
1400
}
1401
1401
1402
- trans_support_nbreaks <- function (trans ) {
1403
- " n" %in% names(formals(trans $ breaks ))
1402
+ support_nbreaks <- function (fun ) {
1403
+ if (inherits(fun , " ggproto_method" )) {
1404
+ fun <- environment(fun )$ f
1405
+ }
1406
+ " n" %in% fn_fmls_names(fun )
1404
1407
}
1405
1408
1406
1409
allow_lambda <- function (x ) {
0 commit comments