Commit e73921c 1 parent 8d7de71 commit e73921c Copy full SHA for e73921c
File tree 1 file changed +16
-17
lines changed
1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change 134
134
};
135
135
let contigousData = $derived (
136
136
data .map ((d ) => {
137
- if (d .label === ' fr' ) {
138
- return d;
139
- }
137
+ // skip for label 'fr'
138
+ if (d .label === ' fr' ) return d;
139
+
140
+ // init
140
141
let contiguousRanges = [];
141
- let start = 0 ;
142
+ let start = null ;
143
+
144
+ //
142
145
for (let i = 0 ; i < d .values .length ; i++ ) {
143
- if (d .values [i]) {
144
- if (start === 0 ) {
145
- // console.log(d.label, i, data_start);
146
- start = i + data_start;
147
- }
148
- } else {
149
- if (start !== 0 ) {
150
- contiguousRanges .push ([start, i + data_start - 1 ]);
151
- start = 0 ;
152
- }
146
+ if (d .values [i] && start === null ) {
147
+ // start a new range
148
+ start = i + selection .start ;
149
+ } else if (! d .values [i] && start !== null ) {
150
+ contiguousRanges .push ([start, i + selection .start - 1 ]);
151
+ start = null ; // reset start
153
152
}
154
153
}
155
- if (start !== 0 ) {
156
- // console.log(d.label, start, d.values.length - 1 + data_start);
157
- contiguousRanges .push ([start, d .values .length - 1 + data_start ]);
154
+ // if range is still open at the end
155
+ if ( start !== null ) {
156
+ contiguousRanges .push ([start, d .values .length + selection . start - 1 ]);
158
157
}
159
158
return {
160
159
label: d .label ,
You can’t perform that action at this time.
0 commit comments