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 = (() => {
63
63
const pointers = series . map ( ( _ ) => 0 ) ; // Index of current data point in each series
64
64
const x_at = ( series_idx ) =>
65
65
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 ) {
74
68
let idx_of_xmin = series_idxs [ 0 ] ;
75
69
for ( const series_idx of series_idxs ) {
76
70
if ( x_at ( series_idx ) < x_at ( idx_of_xmin ) ) idx_of_xmin = series_idx ;
@@ -79,6 +73,9 @@ sqlpage_chart = (() => {
79
73
const new_category = x_at ( idx_of_xmin ) ;
80
74
if ( ! categoriesSet . has ( new_category ) ) categoriesSet . add ( new_category ) ;
81
75
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
+ }
82
79
}
83
80
// Create a map of category -> value for each series and rebuild
84
81
return series . map ( ( s ) => {
You can’t perform that action at this time.
0 commit comments