Skip to content

Commit 78ecf62

Browse files
committed
early exit on zero-range limits
1 parent 2799a86 commit 78ecf62

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

R/scale-.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,16 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
737737
limits <- oob_squish(limits, domain)
738738
}
739739

740+
# Compute `zero_range()` in transformed space in case `limits` in data space
741+
# don't support conversion to numeric (#5304)
742+
if (zero_range(as.numeric(limits))) {
743+
return(limits[1])
744+
}
745+
740746
# Limits in transformed space need to be converted back to data space
741747
limits <- transformation$inverse(limits)
742748

743-
# Compute `zero_range()` in transformed space in case `limits` in data space
744-
# don't support conversion to numeric (#5304)
745-
if (zero_range(as.numeric(transformation$transform(limits)))) {
746-
breaks <- limits[1]
747-
} else if (is.waive(self$breaks)) {
749+
if (is.waive(self$breaks)) {
748750
if (!is.null(self$n.breaks) && support_nbreaks(transformation$breaks)) {
749751
breaks <- transformation$breaks(limits, self$n.breaks)
750752
} else {

0 commit comments

Comments
 (0)