Skip to content

Commit 8170e29

Browse files
author
David Buezas
committed
replace unavailable with undefined so plotly keeps numeric axes
1 parent 202b416 commit 8170e29

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/plotly-graph-card.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class PlotlyGraph extends HTMLElement {
216216
trace.entity_id !== entityId || trace.visible !== "legendonly"
217217
)
218218
);
219-
while (!this.hass) await sleep(100)
219+
while (!this.hass) await sleep(100);
220220
await this.cache.update(range, !this.isBrowsing, entityNames, this.hass);
221221

222222
await this.plot();
@@ -260,7 +260,9 @@ export class PlotlyGraph extends HTMLElement {
260260
shape: "hv",
261261
},
262262
x: history.map(({ last_changed }) => new Date(last_changed)),
263-
y: history.map(({ state }) => state),
263+
y: history.map(({ state }) =>
264+
state === "unavailable" ? undefined : state
265+
),
264266
yaxis: "y" + (yaxis_idx == 0 ? "" : yaxis_idx + 1),
265267
},
266268
trace
@@ -337,9 +339,12 @@ export class PlotlyGraph extends HTMLElement {
337339
const { createCardElement } = await (window as any).loadCardHelpers();
338340

339341
const historyGraphCard = createCardElement({
340-
type: "history-graph",entities:['sun.sun']
342+
type: "history-graph",
343+
entities: ["sun.sun"],
344+
hours_to_show: 1,
345+
refresh_interval: 0,
341346
});
342-
while (!historyGraphCard.constructor.getConfigElement) await sleep(100)
347+
while (!historyGraphCard.constructor.getConfigElement) await sleep(100);
343348
return historyGraphCard.constructor.getConfigElement();
344349
}
345350
}

0 commit comments

Comments
 (0)