File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -63,14 +63,8 @@ sqlpage_chart = (() => {
6363 const pointers = series . map ( ( _ ) => 0 ) ; // Index of current data point in each series
6464 const x_at = ( series_idx ) =>
6565 series [ series_idx ] . data [ pointers [ series_idx ] ] . x ;
66- let series_idxs = Array . from ( { length : series . length } , ( _ , i ) => i ) ;
67- while ( true ) {
68- // indices of series that have data points left
69- series_idxs = series_idxs . filter (
70- ( i ) => pointers [ i ] < series [ i ] . data . length ,
71- ) ;
72- if ( series_idxs . length === 0 ) break ;
73-
66+ const series_idxs = series . flatMap ( ( s , i ) => ( s . data . length ? i : [ ] ) ) ;
67+ while ( series_idxs . length > 0 ) {
7468 let idx_of_xmin = series_idxs [ 0 ] ;
7569 for ( const series_idx of series_idxs ) {
7670 if ( x_at ( series_idx ) < x_at ( idx_of_xmin ) ) idx_of_xmin = series_idx ;
@@ -79,6 +73,9 @@ sqlpage_chart = (() => {
7973 const new_category = x_at ( idx_of_xmin ) ;
8074 if ( ! categoriesSet . has ( new_category ) ) categoriesSet . add ( new_category ) ;
8175 pointers [ idx_of_xmin ] ++ ;
76+ if ( pointers [ idx_of_xmin ] >= series [ idx_of_xmin ] . data . length ) {
77+ series_idxs . splice ( series_idxs . indexOf ( idx_of_xmin ) , 1 ) ;
78+ }
8279 }
8380 // Create a map of category -> value for each series and rebuild
8481 return series . map ( ( s ) => {
You can’t perform that action at this time.
0 commit comments