mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Align charts when show_names: false (#15782)
* Align charts when show_names: false * fixes per code review
This commit is contained in:
parent
27808c9853
commit
020aab0584
@ -143,11 +143,16 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
afterUpdate: (y) => {
|
afterUpdate: (y) => {
|
||||||
|
const yWidth = this.showNames
|
||||||
|
? y.width ?? 0
|
||||||
|
: computeRTL(this.hass)
|
||||||
|
? 0
|
||||||
|
: y.left ?? 0;
|
||||||
if (
|
if (
|
||||||
this._yWidth !== Math.floor(y.width) &&
|
this._yWidth !== Math.floor(yWidth) &&
|
||||||
y.ticks.length === this.data.length
|
y.ticks.length === this.data.length
|
||||||
) {
|
) {
|
||||||
this._yWidth = Math.floor(y.width);
|
this._yWidth = Math.floor(yWidth);
|
||||||
fireEvent(this, "y-width-changed", {
|
fireEvent(this, "y-width-changed", {
|
||||||
value: this._yWidth,
|
value: this._yWidth,
|
||||||
chartIndex: this.chartIndex,
|
chartIndex: this.chartIndex,
|
||||||
|
@ -175,15 +175,14 @@ export class StateHistoryCharts extends LitElement {
|
|||||||
if (changedProps.has("_chartCount")) {
|
if (changedProps.has("_chartCount")) {
|
||||||
if (this._chartCount < this._childYWidths.length) {
|
if (this._chartCount < this._childYWidths.length) {
|
||||||
this._childYWidths.length = this._chartCount;
|
this._childYWidths.length = this._chartCount;
|
||||||
this._maxYWidth =
|
this._maxYWidth = Math.max(...Object.values(this._childYWidths), 0);
|
||||||
this._childYWidths.length === 0 ? 0 : Math.max(...this._childYWidths);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _yWidthChanged(e: CustomEvent<HASSDomEvents["y-width-changed"]>) {
|
private _yWidthChanged(e: CustomEvent<HASSDomEvents["y-width-changed"]>) {
|
||||||
this._childYWidths[e.detail.chartIndex] = e.detail.value;
|
this._childYWidths[e.detail.chartIndex] = e.detail.value;
|
||||||
this._maxYWidth = Math.max(...this._childYWidths);
|
this._maxYWidth = Math.max(...Object.values(this._childYWidths), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _isHistoryEmpty(): boolean {
|
private _isHistoryEmpty(): boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user