mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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) => {
|
||||
const yWidth = this.showNames
|
||||
? y.width ?? 0
|
||||
: computeRTL(this.hass)
|
||||
? 0
|
||||
: y.left ?? 0;
|
||||
if (
|
||||
this._yWidth !== Math.floor(y.width) &&
|
||||
this._yWidth !== Math.floor(yWidth) &&
|
||||
y.ticks.length === this.data.length
|
||||
) {
|
||||
this._yWidth = Math.floor(y.width);
|
||||
this._yWidth = Math.floor(yWidth);
|
||||
fireEvent(this, "y-width-changed", {
|
||||
value: this._yWidth,
|
||||
chartIndex: this.chartIndex,
|
||||
|
@ -175,15 +175,14 @@ export class StateHistoryCharts extends LitElement {
|
||||
if (changedProps.has("_chartCount")) {
|
||||
if (this._chartCount < this._childYWidths.length) {
|
||||
this._childYWidths.length = this._chartCount;
|
||||
this._maxYWidth =
|
||||
this._childYWidths.length === 0 ? 0 : Math.max(...this._childYWidths);
|
||||
this._maxYWidth = Math.max(...Object.values(this._childYWidths), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _yWidthChanged(e: CustomEvent<HASSDomEvents["y-width-changed"]>) {
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user