Skip to content

Commit 5872bae

Browse files
committed
deal with NA/NULL breaks earlier
1 parent 2610840 commit 5872bae

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

R/scale-.R

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,18 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
717717
return(numeric())
718718
}
719719
transformation <- self$get_transformation()
720+
breaks <- self$breaks %|W|% transformation$breaks
721+
722+
if (is.null(breaks)) {
723+
return(NULL)
724+
}
725+
if (identical(breaks, NA)) {
726+
cli::cli_abort(
727+
"Invalid {.arg breaks} specification. Use {.code NULL}, not {.code NA}.",
728+
call = self$call
729+
)
730+
}
731+
720732
# Ensure limits don't exceed domain (#980)
721733
domain <- suppressWarnings(transformation$transform(transformation$domain))
722734
domain <- sort(domain)
@@ -728,17 +740,6 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
728740
# Limits in transformed space need to be converted back to data space
729741
limits <- transformation$inverse(limits)
730742

731-
if (is.null(self$breaks)) {
732-
return(NULL)
733-
}
734-
735-
if (identical(self$breaks, NA)) {
736-
cli::cli_abort(
737-
"Invalid {.arg breaks} specification. Use {.code NULL}, not {.code NA}.",
738-
call = self$call
739-
)
740-
}
741-
742743
# Compute `zero_range()` in transformed space in case `limits` in data space
743744
# don't support conversion to numeric (#5304)
744745
if (zero_range(as.numeric(transformation$transform(limits)))) {

0 commit comments

Comments
 (0)