Skip to content

Commit 1660db8

Browse files
committed
Fix #125 dataseries disappear after lots of zooming/moving/period changing
1 parent cf4f65c commit 1660db8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/plotly-graph-card.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,14 @@ export class PlotlyGraph extends HTMLElement {
585585
}
586586
patchLonelyDatapoints(xs, ys);
587587

588+
if (xs.length === 0 && ys.length === 0) {
589+
/*
590+
Traces with no data are removed from the legend by plotly.
591+
Setting them to have null element prevents that.
592+
*/
593+
xs = [null];
594+
ys = [null];
595+
}
588596
const customdatum = { unit_of_measurement: unit, name, attributes };
589597
const customdata = xs.map(() => customdatum);
590598
const mergedTrace = merge(

0 commit comments

Comments
 (0)