Skip to content

Commit

Permalink
fix(line): using sampling with lttb, use a variable instead of an arr…
Browse files Browse the repository at this point in the history
…ay. close apache#14689
  • Loading branch information
fuchunhui committed Feb 11, 2022
1 parent 1661f9b commit 071ffc2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/data/DataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,14 +965,19 @@ class DataStore {
maxArea = -1;

nextRawIndex = frameStart;
const appendNaNList = [];

let firstNaNIndex = -1;
let countNaN = 0;
// Find a point from current frame that construct a triangel with largest area with previous selected point
// And the average of next frame.
for (let idx = frameStart; idx < frameEnd; idx++) {
const rawIndex = this.getRawIndex(idx);
const y = dimStore[rawIndex] as number;
if (isNaN(y)) {
appendNaNList.push(rawIndex);
countNaN++;
if (firstNaNIndex < 0) {
firstNaNIndex = rawIndex;
}
continue;
}
// Calculate triangle area over three buckets
Expand All @@ -985,8 +990,8 @@ class DataStore {
}
}

if (appendNaNList.length && appendNaNList.length !== frameEnd - frameStart) {
newIndices[sampledIndex++] = appendNaNList[0]; // append first NaN point in every bucket
if (countNaN > 0 && countNaN < frameEnd - frameStart) {
newIndices[sampledIndex++] = firstNaNIndex; // append first NaN point in every bucket
}

newIndices[sampledIndex++] = nextRawIndex;
Expand Down

0 comments on commit 071ffc2

Please sign in to comment.