mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Add "show_names" option to history graphs (#14546)
This commit is contained in:
parent
08ffe375b9
commit
8ba46f7f57
@ -26,7 +26,7 @@ class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
@property() public identifier?: string;
|
@property() public identifier?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public isSingleDevice = false;
|
@property({ type: Boolean }) public showNames = true;
|
||||||
|
|
||||||
@property({ attribute: false }) public endTime!: Date;
|
@property({ attribute: false }) public endTime!: Date;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class StateHistoryChartLine extends LitElement {
|
|||||||
propagate: true,
|
propagate: true,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
display: !this.isSingleDevice,
|
display: this.showNames,
|
||||||
labels: {
|
labels: {
|
||||||
usePointStyle: true,
|
usePointStyle: true,
|
||||||
},
|
},
|
||||||
|
@ -83,7 +83,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
|
|
||||||
@property() public identifier?: string;
|
@property() public identifier?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public isSingleDevice = false;
|
@property({ type: Boolean }) public showNames = true;
|
||||||
|
|
||||||
@property({ type: Boolean }) public chunked = false;
|
@property({ type: Boolean }) public chunked = false;
|
||||||
|
|
||||||
@ -175,8 +175,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
drawTicks: false,
|
drawTicks: false,
|
||||||
},
|
},
|
||||||
ticks: {
|
ticks: {
|
||||||
display:
|
display: this.chunked || this.showNames,
|
||||||
this.chunked || !this.isSingleDevice || this.data.length !== 1,
|
|
||||||
},
|
},
|
||||||
afterSetDimensions: (y) => {
|
afterSetDimensions: (y) => {
|
||||||
y.maxWidth = y.chart.width * 0.18;
|
y.maxWidth = y.chart.width * 0.18;
|
||||||
|
@ -48,7 +48,7 @@ class StateHistoryCharts extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean, attribute: "up-to-now" }) public upToNow = false;
|
@property({ type: Boolean, attribute: "up-to-now" }) public upToNow = false;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "no-single" }) public noSingle = false;
|
@property({ type: Boolean }) public showNames = true;
|
||||||
|
|
||||||
@property({ type: Boolean }) public isLoadingData = false;
|
@property({ type: Boolean }) public isLoadingData = false;
|
||||||
|
|
||||||
@ -128,8 +128,7 @@ class StateHistoryCharts extends LitElement {
|
|||||||
.unit=${item.unit}
|
.unit=${item.unit}
|
||||||
.data=${item.data}
|
.data=${item.data}
|
||||||
.identifier=${item.identifier}
|
.identifier=${item.identifier}
|
||||||
.isSingleDevice=${!this.noSingle &&
|
.showNames=${this.showNames}
|
||||||
this.historyData.line?.length === 1}
|
|
||||||
.endTime=${this._computedEndTime}
|
.endTime=${this._computedEndTime}
|
||||||
.names=${this.names}
|
.names=${this.names}
|
||||||
></state-history-chart-line>
|
></state-history-chart-line>
|
||||||
@ -141,8 +140,7 @@ class StateHistoryCharts extends LitElement {
|
|||||||
.data=${item}
|
.data=${item}
|
||||||
.startTime=${this._computedStartTime}
|
.startTime=${this._computedStartTime}
|
||||||
.endTime=${this._computedEndTime}
|
.endTime=${this._computedEndTime}
|
||||||
.isSingleDevice=${!this.noSingle &&
|
.showNames=${this.showNames}
|
||||||
this.historyData.timeline?.length === 1}
|
|
||||||
.names=${this.names}
|
.names=${this.names}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.chunked=${this.virtualize}
|
.chunked=${this.virtualize}
|
||||||
|
@ -67,12 +67,14 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
.statTypes=${statTypes}
|
.statTypes=${statTypes}
|
||||||
.names=${this._statNames}
|
.names=${this._statNames}
|
||||||
hideLegend
|
hideLegend
|
||||||
|
.showNames=${false}
|
||||||
></statistics-chart>`
|
></statistics-chart>`
|
||||||
: html`<state-history-charts
|
: html`<state-history-charts
|
||||||
up-to-now
|
up-to-now
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.historyData=${this._stateHistory}
|
.historyData=${this._stateHistory}
|
||||||
.isLoadingData=${!this._stateHistory}
|
.isLoadingData=${!this._stateHistory}
|
||||||
|
.showNames=${false}
|
||||||
></state-history-charts>`}`
|
></state-history-charts>`}`
|
||||||
: ""}`;
|
: ""}`;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,6 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.historyData=${this._stateHistory}
|
.historyData=${this._stateHistory}
|
||||||
.endTime=${this._endDate}
|
.endTime=${this._endDate}
|
||||||
no-single
|
|
||||||
>
|
>
|
||||||
</state-history-charts>
|
</state-history-charts>
|
||||||
`}
|
`}
|
||||||
|
@ -144,7 +144,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
.historyData=${this._stateHistory}
|
.historyData=${this._stateHistory}
|
||||||
.names=${this._names}
|
.names=${this._names}
|
||||||
up-to-now
|
up-to-now
|
||||||
no-single
|
.showNames=${this._config.show_names}
|
||||||
></state-history-charts>
|
></state-history-charts>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
|
@ -300,6 +300,7 @@ export interface HistoryGraphCardConfig extends LovelaceCardConfig {
|
|||||||
hours_to_show?: number;
|
hours_to_show?: number;
|
||||||
refresh_interval?: number;
|
refresh_interval?: number;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
show_names?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StatisticsGraphCardConfig extends LovelaceCardConfig {
|
export interface StatisticsGraphCardConfig extends LovelaceCardConfig {
|
||||||
|
@ -4,6 +4,7 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import {
|
import {
|
||||||
array,
|
array,
|
||||||
assert,
|
assert,
|
||||||
|
boolean,
|
||||||
number,
|
number,
|
||||||
object,
|
object,
|
||||||
optional,
|
optional,
|
||||||
@ -28,6 +29,7 @@ const cardConfigStruct = assign(
|
|||||||
title: optional(string()),
|
title: optional(string()),
|
||||||
hours_to_show: optional(number()),
|
hours_to_show: optional(number()),
|
||||||
refresh_interval: optional(number()),
|
refresh_interval: optional(number()),
|
||||||
|
show_names: optional(boolean()),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user