@@ -637,36 +637,18 @@ Scale <- ggproto("Scale", NULL,
637
637
}
638
638
)
639
639
640
- check_breaks_labels <- function (breaks , labels , call = NULL ) {
641
- if (is.null(breaks ) || is.null(labels )) {
642
- return (invisible ())
643
- }
644
640
645
- bad_labels <- is.atomic(breaks ) && is.atomic(labels ) &&
646
- length(breaks ) != length(labels )
647
- if (bad_labels ) {
648
- cli :: cli_abort(
649
- " {.arg breaks} and {.arg labels} must have the same length." ,
650
- call = call
651
- )
652
- }
653
641
654
- invisible ()
655
- }
642
+ # ScaleContinuous ---------------------------------------------------------
656
643
644
+ # This needs to be defined prior to the Scale subclasses.
657
645
default_transform <- function (self , x ) {
658
646
transformation <- self $ get_transformation()
659
647
new_x <- transformation $ transform(x )
660
648
check_transformation(x , new_x , transformation $ name , call = self $ call )
661
649
new_x
662
650
}
663
651
664
- has_default_transform <- function (scale ) {
665
- transform_method <- environment(scale $ transform )$ f
666
- identical(default_transform , transform_method ) || identical(identity , transform_method )
667
- }
668
- # ScaleContinuous ---------------------------------------------------------
669
-
670
652
# ' @rdname ggplot2-ggproto
671
653
# ' @format NULL
672
654
# ' @usage NULL
@@ -1426,6 +1408,29 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1426
1408
)
1427
1409
1428
1410
# Helpers -----------------------------------------------------------------
1411
+
1412
+ check_breaks_labels <- function (breaks , labels , call = NULL ) {
1413
+ if (is.null(breaks ) || is.null(labels )) {
1414
+ return (invisible ())
1415
+ }
1416
+
1417
+ bad_labels <- is.atomic(breaks ) && is.atomic(labels ) &&
1418
+ length(breaks ) != length(labels )
1419
+ if (bad_labels ) {
1420
+ cli :: cli_abort(
1421
+ " {.arg breaks} and {.arg labels} must have the same length." ,
1422
+ call = call
1423
+ )
1424
+ }
1425
+
1426
+ invisible ()
1427
+ }
1428
+
1429
+ has_default_transform <- function (scale ) {
1430
+ transform_method <- environment(scale $ transform )$ f
1431
+ identical(default_transform , transform_method ) || identical(identity , transform_method )
1432
+ }
1433
+
1429
1434
# In place modification of a scale to change the primary axis
1430
1435
scale_flip_position <- function (scale ) {
1431
1436
scale $ position <- opposite_position(scale $ position )
0 commit comments