@@ -92,14 +92,9 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
92
92
}
93
93
},
94
94
95
- # If range not available from discrete range, implies discrete scale been
96
- # used with purely continuous data, so construct limits accordingly
97
95
get_limits = function (self ) {
98
96
if (self $ is_empty()) return (c(0 , 1 ))
99
-
100
- dis_limits <- function (x ) seq.int(floor(min(x )), ceiling(max(x )), by = 1L )
101
-
102
- self $ limits %|| % self $ range $ range %|| % dis_limits(self $ range_c $ range )
97
+ self $ limits %|| % self $ range $ range %|| % integer()
103
98
},
104
99
105
100
is_empty = function (self ) {
@@ -120,16 +115,21 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
120
115
},
121
116
122
117
dimension = function (self , expand = c(0 , 0 )) {
123
- disc_range <- c(1 , length(self $ get_limits()))
124
- disc <- expand_range(disc_range , 0 , expand [2 ], 1 )
125
-
126
- # if no data was trained (i.e. range_c is infinite) return disc range
127
- if (any(is.infinite(self $ range_c $ range ))) {
128
- return (disc )
118
+ c_range <- self $ range_c $ range
119
+ d_range <- self $ range $ range
120
+
121
+ if (self $ is_empty()) {
122
+ c(0 , 1 )
123
+ } else if (is.null(d_range )) { # only continuous
124
+ expand_range(c_range , expand [1 ], 0 , 1 )
125
+ } else if (is.null(c_range )) { # only discrete
126
+ expand_range(c(1 , length(d_range )), 0 , expand [2 ], 1 )
127
+ } else { # both
128
+ range(
129
+ expand_range(c_range , expand [1 ], 0 , 1 ),
130
+ expand_range(c(1 , length(d_range )), 0 , expand [2 ], 1 )
131
+ )
129
132
}
130
-
131
- cont <- expand_range(self $ range_c $ range , expand [1 ], 0 , expand [2 ])
132
- range(disc , cont )
133
133
},
134
134
135
135
clone = function (self ) {
0 commit comments