Skip to content

Commit 4922995

Browse files
committed
move helpers to helper section
1 parent 2a01b56 commit 4922995

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

R/scale-.R

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -637,36 +637,18 @@ Scale <- ggproto("Scale", NULL,
637637
}
638638
)
639639

640-
check_breaks_labels <- function(breaks, labels, call = NULL) {
641-
if (is.null(breaks) || is.null(labels)) {
642-
return(invisible())
643-
}
644640

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-
}
653641

654-
invisible()
655-
}
642+
# ScaleContinuous ---------------------------------------------------------
656643

644+
# This needs to be defined prior to the Scale subclasses.
657645
default_transform <- function(self, x) {
658646
transformation <- self$get_transformation()
659647
new_x <- transformation$transform(x)
660648
check_transformation(x, new_x, transformation$name, call = self$call)
661649
new_x
662650
}
663651

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-
670652
#' @rdname ggplot2-ggproto
671653
#' @format NULL
672654
#' @usage NULL
@@ -1426,6 +1408,29 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
14261408
)
14271409

14281410
# 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+
14291434
# In place modification of a scale to change the primary axis
14301435
scale_flip_position <- function(scale) {
14311436
scale$position <- opposite_position(scale$position)

0 commit comments

Comments
 (0)