@@ -121,14 +121,24 @@ export function computeMetricPlotData(masterData, xColumn, metric, xLim) {
121121 ( r ) => r [ metric ] != null && r [ metric ] !== undefined ,
122122 ) ;
123123 if ( xLim ) {
124- const sorted = relevant . sort ( ( a , b ) => a [ xColumn ] - b [ xColumn ] ) ;
125- let lo = 0 ;
126- let hi = sorted . length - 1 ;
127- while ( lo < sorted . length && sorted [ lo ] [ xColumn ] < xLim [ 0 ] ) lo ++ ;
128- while ( hi >= 0 && sorted [ hi ] [ xColumn ] > xLim [ 1 ] ) hi -- ;
129- lo = Math . max ( 0 , lo - 1 ) ;
130- hi = Math . min ( sorted . length - 1 , hi + 1 ) ;
131- relevant = sorted . slice ( lo , hi + 1 ) ;
124+ const groups = new Map ( ) ;
125+ for ( const r of relevant ) {
126+ const key = `${ r . run || "" } \0${ r . data_type || "original" } ` ;
127+ if ( ! groups . has ( key ) ) groups . set ( key , [ ] ) ;
128+ groups . get ( key ) . push ( r ) ;
129+ }
130+ const filtered = [ ] ;
131+ for ( const [ , rows ] of groups ) {
132+ rows . sort ( ( a , b ) => a [ xColumn ] - b [ xColumn ] ) ;
133+ let lo = 0 ;
134+ let hi = rows . length - 1 ;
135+ while ( lo < rows . length && rows [ lo ] [ xColumn ] < xLim [ 0 ] ) lo ++ ;
136+ while ( hi >= 0 && rows [ hi ] [ xColumn ] > xLim [ 1 ] ) hi -- ;
137+ lo = Math . max ( 0 , lo - 1 ) ;
138+ hi = Math . min ( rows . length - 1 , hi + 1 ) ;
139+ filtered . push ( ...rows . slice ( lo , hi + 1 ) ) ;
140+ }
141+ relevant = filtered ;
132142 }
133143 const originals = relevant . filter (
134144 ( r ) => r . data_type === "original" || ! r . data_type ,
0 commit comments