Skip to content

Commit 34b3e62

Browse files
author
David Buezas
committed
fixed default axes.
1 parent 9cd6b3b commit 34b3e62

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ defaults:
290290
fill: tozeroy
291291
line:
292292
width: 2
293-
yaxis:
293+
yaxes:
294294
fixedrange: true # disables vertical zoom & scroll
295295
```
296296

src/plotly-graph-card.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class PlotlyGraph extends HTMLElement {
216216
},
217217
},
218218
config.defaults?.entity,
219-
entity,
219+
entity
220220
);
221221

222222
return merge(
@@ -227,19 +227,20 @@ export class PlotlyGraph extends HTMLElement {
227227
{ lambda: entity.lambda ? window.eval(entity.lambda) : undefined }
228228
);
229229
}),
230-
231-
layout: {
232-
yaxis: config.defaults?.yaxis,
233-
yaxis2: config.defaults?.yaxis,
234-
yaxis3: config.defaults?.yaxis,
235-
yaxis4: config.defaults?.yaxis,
236-
yaxis5: config.defaults?.yaxis,
237-
yaxis6: config.defaults?.yaxis,
238-
yaxis7: config.defaults?.yaxis,
239-
yaxis8: config.defaults?.yaxis,
240-
yaxis9: config.defaults?.yaxis,
241-
...config.layout,
242-
},
230+
layout: merge(
231+
{
232+
yaxis: merge({}, config.defaults?.yaxes),
233+
yaxis2: merge({}, config.defaults?.yaxes),
234+
yaxis3: merge({}, config.defaults?.yaxes),
235+
yaxis4: merge({}, config.defaults?.yaxes),
236+
yaxis5: merge({}, config.defaults?.yaxes),
237+
yaxis6: merge({}, config.defaults?.yaxes),
238+
yaxis7: merge({}, config.defaults?.yaxes),
239+
yaxis8: merge({}, config.defaults?.yaxes),
240+
yaxis9: merge({}, config.defaults?.yaxes),
241+
},
242+
config.layout
243+
),
243244
config: {
244245
...config.config,
245246
},
@@ -331,7 +332,7 @@ export class PlotlyGraph extends HTMLElement {
331332
console.error(e);
332333
}
333334
}
334-
const customdatum = { unit_of_measurement: unit, name };
335+
const customdatum = { unit_of_measurement: unit, name, attributes };
335336
const customdata = xs.map(() => customdatum);
336337
const mergedTrace = merge(
337338
{
@@ -471,4 +472,4 @@ window.customCards.push({
471472
description: "Plotly in HA", // Optional
472473
});
473474

474-
customElements.define(componentName, PlotlyGraph);
475+
customElements.define(componentName, PlotlyGraph);

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type InputConfig = {
1717
})[];
1818
defaults?: {
1919
entity?: Partial<Plotly.PlotData>,
20-
yaxis?: Partial<Plotly.Layout["yaxis"]>,
20+
yaxes?: Partial<Plotly.Layout["yaxis"]>,
2121
}
2222
layout?: Partial<Plotly.Layout>;
2323
config?: Partial<Plotly.Config>;

0 commit comments

Comments
 (0)