Skip to content

Commit ad4a6d0

Browse files
committed
fix removeOutOfRange not removing right side of the range
1 parent 3f47965 commit ad4a6d0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/plotly-graph-card.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@ const componentName = isProduction ? "plotly-graph" : "plotly-graph-dev";
2727

2828
function removeOutOfRange(data: EntityData, range: TimestampRange) {
2929
let first = -1;
30-
let last = -1;
3130

3231
for (let i = 0; i < data.xs.length; i++) {
3332
if (+data.xs[i]! < range[0]) first = i;
33+
}
34+
if (first > -1) {
35+
data.xs.splice(0, first);
36+
data.ys.splice(0, first);
37+
data.states.splice(0, first);
38+
data.statistics.splice(0, first);
39+
}
40+
let last = -1;
41+
for (let i = data.xs.length - 1; i >= 0; i--) {
3442
if (+data.xs[i]! > range[1]) last = i;
3543
}
3644
if (last > -1) {
@@ -39,12 +47,6 @@ function removeOutOfRange(data: EntityData, range: TimestampRange) {
3947
data.states.splice(last);
4048
data.statistics.splice(last);
4149
}
42-
if (first > -1) {
43-
data.xs.splice(0, first);
44-
data.ys.splice(0, first);
45-
data.states.splice(0, first);
46-
data.statistics.splice(0, first);
47-
}
4850
}
4951

5052
console.info(

0 commit comments

Comments
 (0)