@@ -84,8 +84,8 @@ function autoScaleRangeY(scale, dimensions) {
8484 const { insetTop, insetBottom} = scale ;
8585 const { height, marginTop = 0 , marginBottom = 0 } = dimensions ;
8686 scale . range = [ height - marginBottom - insetBottom , marginTop + insetTop ] ;
87- if ( isOrdinalScale ( scale ) ) scale . range . reverse ( ) ;
88- else scale . range = piecewiseRange ( scale ) ;
87+ if ( ! isOrdinalScale ( scale ) ) scale . range = piecewiseRange ( scale ) ;
88+ else scale . range . reverse ( ) ;
8989 scale . scale . range ( scale . range ) ;
9090 }
9191 autoScaleRound ( scale ) ;
@@ -111,10 +111,10 @@ function roundError({scale}) {
111111 return ( step - Math . floor ( step ) ) * m ;
112112}
113113
114- function piecewiseRange ( { scale, range } ) {
115- const length = scale . domain ( ) . length ;
116- if ( ! ( length > 2 ) ) return range ;
117- const [ start , end ] = range ;
114+ function piecewiseRange ( scale ) {
115+ const length = scale . scale . domain ( ) . length + isThresholdScale ( scale ) ;
116+ if ( ! ( length > 2 ) ) return scale . range ;
117+ const [ start , end ] = scale . range ;
118118 return Array . from ( { length} , ( _ , i ) => start + i / ( length - 1 ) * ( end - start ) ) ;
119119}
120120
@@ -217,6 +217,10 @@ export function isOrdinalScale({type}) {
217217 return type === "ordinal" || type === "point" || type === "band" ;
218218}
219219
220+ function isThresholdScale ( { type} ) {
221+ return type === "threshold" ;
222+ }
223+
220224function isBandScale ( { type} ) {
221225 return type === "point" || type === "band" ;
222226}
0 commit comments