Skip to content

Commit 7bbad15

Browse files
author
David Buezas
committed
corrected height
1 parent e09e647 commit 7bbad15

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/date-ranges.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const subtract_single_single = (
2222
if (a_start < b_start && b_start <= a_end && a_end <= b_end)
2323
return [[a_start, b_start - 1]];
2424
else {
25-
console.log("---------");
25+
console.log("----ERROR TO REPORT-----");
2626
console.log([a_start, a_end]);
2727
console.log([b_start, b_end]);
2828
throw new Error(

src/plotly-graph-card.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ export class PlotlyGraph extends HTMLElement {
118118
// The user supplied configuration. Throw an exception and Lovelace will
119119
// render an error card.
120120
async setConfig(config) {
121+
if (typeof config.entities[0] === "string") {
122+
config = {
123+
...config,
124+
entities: config.entities.map((name) => ({ entity: name })),
125+
};
126+
}
121127
const was = this.config;
122128
this.config = JSON.parse(JSON.stringify(config));
123129
const is = this.config;
@@ -135,7 +141,7 @@ export class PlotlyGraph extends HTMLElement {
135141
const { histories, attributes } = this.cache;
136142

137143
const units = Array.from(
138-
new Set(Object.values(attributes).map((a) => a.unit_of_measurement))
144+
new Set(Object.values(attributes).map((a) => a.unit_of_measurement || ""))
139145
);
140146

141147
this.data = entities.map((trace) => {
@@ -145,7 +151,11 @@ export class PlotlyGraph extends HTMLElement {
145151
const yaxis_idx = units.indexOf(attribute.unit_of_measurement);
146152
return {
147153
name: trace.name || attribute.friendly_name || entity_id,
148-
hovertemplate: `%{y} ${attribute.unit_of_measurement || ""}`,
154+
hovertemplate: `<b>%{x} ${attribute.unit_of_measurement}</b><br>%{y}`,
155+
line: {
156+
width: 1,
157+
shape: "hv",
158+
},
149159
...trace,
150160
x: history.map(({ last_changed }) => new Date(last_changed)),
151161
y: history.map(({ state }) => state),
@@ -197,7 +207,6 @@ export class PlotlyGraph extends HTMLElement {
197207
modeBarButtonsToRemove: ["resetScale2d", "toImage"],
198208
...config.config,
199209
};
200-
console.log(this.data, layout);
201210
this.isInternalRelayout = true;
202211
await Plotly.react(contentEl, data, layout, plotlyConfig);
203212
this.isInternalRelayout = false;

src/plotly.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// import Plotly from "plotly.js-dist";
2+
// export default Plotly as typeof import("plotly.js");
3+
14
window.global = window;
25
var Plotly = require("plotly.js/lib/core") as typeof import("plotly.js");
36
//@ts-ignore

src/themed-layout.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import merge from "lodash/merge";
22
import { HATheme } from "./types";
33

44
const defaultLayout: Partial<Plotly.Layout> = {
5-
height: 260,
5+
height: 285,
66
xaxis: {
77
automargin: true,
88
},
@@ -66,7 +66,6 @@ export default function getThemedLayout(
6666
paper_bgcolor: haTheme["--card-background-color"],
6767
plot_bgcolor: haTheme["--card-background-color"],
6868
xaxis: { ...axisStyle },
69-
7069
yaxis: { ...axisStyle },
7170
yaxis2: { ...axisStyle },
7271
yaxis3: { ...axisStyle },

0 commit comments

Comments
 (0)