20220601.0 (#12843)

This commit is contained in:
Bram Kragten 2022-06-01 21:57:23 +02:00 committed by GitHub
parent 97f082a384
commit f8af66d310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 18 deletions

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "home-assistant-frontend" name = "home-assistant-frontend"
version = "20220531.0" version = "20220601.0"
license = {text = "Apache-2.0"} license = {text = "Apache-2.0"}
description = "The Home Assistant frontend" description = "The Home Assistant frontend"
readme = "README.md" readme = "README.md"

View File

@ -93,7 +93,7 @@ export class StateHistoryChartTimeline extends LitElement {
@property({ type: Boolean }) public isSingleDevice = false; @property({ type: Boolean }) public isSingleDevice = false;
@property({ type: Boolean }) public dataHasMultipleRows = false; @property({ type: Boolean }) public chunked = false;
@property({ attribute: false }) public startTime!: Date; @property({ attribute: false }) public startTime!: Date;
@ -117,7 +117,6 @@ export class StateHistoryChartTimeline extends LitElement {
public willUpdate(changedProps: PropertyValues) { public willUpdate(changedProps: PropertyValues) {
if (!this.hasUpdated) { if (!this.hasUpdated) {
const narrow = this.narrow; const narrow = this.narrow;
const multipleRows = this.data.length !== 1 || this.dataHasMultipleRows;
this._chartOptions = { this._chartOptions = {
maintainAspectRatio: false, maintainAspectRatio: false,
parsing: false, parsing: false,
@ -163,13 +162,14 @@ export class StateHistoryChartTimeline extends LitElement {
drawTicks: false, drawTicks: false,
}, },
ticks: { ticks: {
display: multipleRows, display:
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;
}, },
afterFit: function (scaleInstance) { afterFit: (scaleInstance) => {
if (multipleRows) { if (this.chunked) {
// ensure all the chart labels are the same width // ensure all the chart labels are the same width
scaleInstance.width = narrow ? 105 : 185; scaleInstance.width = narrow ? 105 : 185;
} }

View File

@ -62,19 +62,19 @@ class StateHistoryCharts extends LitElement {
@eventOptions({ passive: true }) @eventOptions({ passive: true })
protected render(): TemplateResult { protected render(): TemplateResult {
if (!isComponentLoaded(this.hass, "history")) { if (!isComponentLoaded(this.hass, "history")) {
return html` <div class="info"> return html`<div class="info">
${this.hass.localize("ui.components.history_charts.history_disabled")} ${this.hass.localize("ui.components.history_charts.history_disabled")}
</div>`; </div>`;
} }
if (this.isLoadingData && !this.historyData) { if (this.isLoadingData && !this.historyData) {
return html` <div class="info"> return html`<div class="info">
${this.hass.localize("ui.components.history_charts.loading_history")} ${this.hass.localize("ui.components.history_charts.loading_history")}
</div>`; </div>`;
} }
if (this._isHistoryEmpty()) { if (this._isHistoryEmpty()) {
return html` <div class="info"> return html`<div class="info">
${this.hass.localize("ui.components.history_charts.no_history_found")} ${this.hass.localize("ui.components.history_charts.no_history_found")}
</div>`; </div>`;
} }
@ -92,10 +92,12 @@ class StateHistoryCharts extends LitElement {
) )
); );
const combinedItems = chunkData( const combinedItems = this.historyData.timeline.length
this.historyData.timeline, ? (this.virtualize
CANVAS_TIMELINE_ROWS_CHUNK ? chunkData(this.historyData.timeline, CANVAS_TIMELINE_ROWS_CHUNK)
).concat(this.historyData.line); : [this.historyData.timeline]
).concat(this.historyData.line)
: this.historyData.line;
return this.virtualize return this.virtualize
? html`<div class="container ha-scrollbar" @scroll=${this._saveScrollPos}> ? html`<div class="container ha-scrollbar" @scroll=${this._saveScrollPos}>
@ -127,8 +129,7 @@ class StateHistoryCharts extends LitElement {
.data=${item.data} .data=${item.data}
.identifier=${item.identifier} .identifier=${item.identifier}
.isSingleDevice=${!this.noSingle && .isSingleDevice=${!this.noSingle &&
this.historyData.line && this.historyData.line?.length === 1}
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>
@ -140,11 +141,11 @@ class StateHistoryCharts extends LitElement {
.data=${item} .data=${item}
.startTime=${this._computedStartTime} .startTime=${this._computedStartTime}
.endTime=${this._computedEndTime} .endTime=${this._computedEndTime}
.noSingle=${this.noSingle} .isSingleDevice=${!this.noSingle &&
this.historyData.timeline?.length === 1}
.names=${this.names} .names=${this.names}
.narrow=${this.narrow} .narrow=${this.narrow}
.dataHasMultipleRows=${this.historyData.timeline.length && .chunked=${this.virtualize}
this.historyData.timeline.length > 1}
></state-history-chart-timeline> ></state-history-chart-timeline>
</div> `; </div> `;
}; };