@@ -647,34 +647,40 @@ function buildPrimaryBandScale<TDatum>(
647647 range : [ number , number ]
648648) {
649649 // Find the two closest points along axis
650+ // Do not allow the band to be smaller than single pixel of the output range
650651
651652 let impliedBandWidth : number = Math . max ( ...range )
653+ const bandRange : number = Math . max ( ...range )
652654
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 ]
655658
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 )
659662
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 )
663666
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 ) )
667672
668- const diff = Math . abs ( Math . max ( one , two ) - Math . min ( one , two ) )
673+ if ( diff < impliedBandWidth ) {
674+ impliedBandWidth = Math . max ( diff , bandRange )
669675
670- if ( diff < impliedBandWidth ) {
671- impliedBandWidth = diff
676+ if ( impliedBandWidth === bandRange ) {
677+ return
678+ }
679+ }
672680 }
673681 }
674682 }
675- }
676-
677- const bandRange = Math . max ( ...range )
683+ } ) ( )
678684
679685 const bandDomain = d3Range ( bandRange / impliedBandWidth )
680686
0 commit comments