Skip to content

Commit 6676761

Browse files
authored
Map "unavailable" datapoints to null. Fixes #146 (#147)
1 parent e42e4d2 commit 6676761

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/cache/fetch-states.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function fetchStates(
4444
.map((entry) => ({
4545
...entry,
4646
timestamp: +new Date(entry.last_updated || entry.last_changed),
47-
value: "", // may be state or an attribute. Will be set when getting the history
47+
value: null, // may be state or an attribute. Will be set when getting the history
4848
}))
4949
.filter(({ timestamp }) => timestamp);
5050
}

src/cache/fetch-statistics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function fetchStatistics(
2929
.map((entry) => ({
3030
...entry,
3131
timestamp: +new Date(entry.start),
32-
value: "", //depends on the statistic, will be set in getHistory
32+
value: null, //depends on the statistic, will be set in getHistory
3333
}))
3434
.filter(({ timestamp }) => timestamp);
3535
}

src/plotly-graph-card.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ export class PlotlyGraph extends HTMLElement {
610610
if (isEntityIdAttrConfig(trace)) name += ` (${trace.attribute}) `;
611611
if (isEntityIdStatisticsConfig(trace)) name += ` (${trace.statistic}) `;
612612
const xsIn = history.map(({ timestamp }) => new Date(timestamp));
613-
const ysIn: Datum[] = history.map(({ value }) => value);
613+
const ysIn: Datum[] = history.map(({ value }) =>
614+
value === "unavailable" ? null : value
615+
);
614616

615617
let xs: Datum[] = xsIn;
616618
let ys = ysIn;

0 commit comments

Comments
 (0)