@@ -18,6 +18,7 @@ export default function() {
18
18
var i ,
19
19
n = data . length ,
20
20
x ,
21
+ step ,
21
22
values = new Array ( n ) ;
22
23
23
24
for ( i = 0 ; i < n ; ++ i ) {
@@ -45,7 +46,7 @@ export default function() {
45
46
// compare order (>=) rather than strict equality (===)!
46
47
if ( tz [ tz . length - 1 ] >= x1 ) {
47
48
if ( max >= x1 && domain === extent ) {
48
- const step = tickIncrement ( x0 , x1 , tn ) ;
49
+ step = tickIncrement ( x0 , x1 , tn ) ;
49
50
if ( isFinite ( step ) ) {
50
51
if ( step > 0 ) {
51
52
x1 = ( Math . floor ( x1 / step ) + 1 ) * step ;
@@ -75,10 +76,20 @@ export default function() {
75
76
}
76
77
77
78
// Assign data to bins by value, ignoring any outside the domain.
78
- for ( i = 0 ; i < n ; ++ i ) {
79
- x = values [ i ] ;
80
- if ( x != null && x0 <= x && x <= x1 ) {
81
- bins [ bisect ( tz , x , 0 , m ) ] . push ( data [ i ] ) ;
79
+ if ( step && isFinite ( step ) ) {
80
+ step = step < 0 ? - step : 1 / step ;
81
+ for ( i = 0 ; i < n ; ++ i ) {
82
+ x = values [ i ] ;
83
+ if ( x != null && x0 <= x && x <= x1 ) {
84
+ bins [ Math . floor ( ( x - x0 ) * step ) ] . push ( data [ i ] ) ;
85
+ }
86
+ }
87
+ } else {
88
+ for ( i = 0 ; i < n ; ++ i ) {
89
+ x = values [ i ] ;
90
+ if ( x != null && x0 <= x && x <= x1 ) {
91
+ bins [ bisect ( tz , x , 0 , m ) ] . push ( data [ i ] ) ;
92
+ }
82
93
}
83
94
}
84
95
0 commit comments