@@ -647,34 +647,40 @@ function buildPrimaryBandScale<TDatum>(
647
647
range : [ number , number ]
648
648
) {
649
649
// Find the two closest points along axis
650
+ // Do not allow the band to be smaller than single pixel of the output range
650
651
651
652
let impliedBandWidth : number = Math . max ( ...range )
653
+ const bandRange : number = Math . max ( ...range )
652
654
653
- for ( let i = 0 ; i < series . length ; i ++ ) {
654
- const serie = series [ i ]
655
+ ; ( ( ) => {
656
+ for ( let i = 0 ; i < series . length ; i ++ ) {
657
+ const serie = series [ i ]
655
658
656
- for ( let j = 0 ; j < serie . datums . length ; j ++ ) {
657
- const d1 = serie . datums [ j ]
658
- const one = scale ( d1 . primaryValue ?? NaN )
659
+ for ( let j = 0 ; j < serie . datums . length ; j ++ ) {
660
+ const d1 = serie . datums [ j ]
661
+ const one = scale ( d1 . primaryValue ?? NaN )
659
662
660
- for ( let k = 0 ; k < serie . datums . length ; k ++ ) {
661
- const d2 = serie . datums [ k ]
662
- const two = scale ( d2 . primaryValue ?? NaN )
663
+ for ( let k = 0 ; k < serie . datums . length ; k ++ ) {
664
+ const d2 = serie . datums [ k ]
665
+ const two = scale ( d2 . primaryValue ?? NaN )
663
666
664
- if ( one === two ) {
665
- continue
666
- }
667
+ if ( one === two ) {
668
+ continue
669
+ }
670
+
671
+ const diff = Math . abs ( Math . max ( one , two ) - Math . min ( one , two ) )
667
672
668
- const diff = Math . abs ( Math . max ( one , two ) - Math . min ( one , two ) )
673
+ if ( diff < impliedBandWidth ) {
674
+ impliedBandWidth = Math . max ( diff , bandRange )
669
675
670
- if ( diff < impliedBandWidth ) {
671
- impliedBandWidth = diff
676
+ if ( impliedBandWidth === bandRange ) {
677
+ return
678
+ }
679
+ }
672
680
}
673
681
}
674
682
}
675
- }
676
-
677
- const bandRange = Math . max ( ...range )
683
+ } ) ( )
678
684
679
685
const bandDomain = d3Range ( bandRange / impliedBandWidth )
680
686
0 commit comments