From 730cea66465a0d72fdb4ce79aa8e2fb148eed498 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Mon, 3 Feb 2025 16:59:43 +0200 Subject: [PATCH] Workaround for chart size bug in editor preview (#24040) --- src/components/chart/state-history-chart-line.ts | 3 ++- src/components/chart/statistics-chart.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/chart/state-history-chart-line.ts b/src/components/chart/state-history-chart-line.ts index 2167138aa2..be9e71e845 100644 --- a/src/components/chart/state-history-chart-line.ts +++ b/src/components/chart/state-history-chart-line.ts @@ -247,7 +247,8 @@ export class StateHistoryChartLine extends LitElement { margin: 5, formatter: (value: number) => { const label = formatNumber(value, this.hass.locale); - const width = measureTextWidth(label, 12) + 5; + // adding 5px extra because preview is not accurate #24027 + const width = measureTextWidth(label, 12) + 5 + 5; if (width > this._yWidth) { this._yWidth = width; fireEvent(this, "y-width-changed", { diff --git a/src/components/chart/statistics-chart.ts b/src/components/chart/statistics-chart.ts index 1724603002..62090d23ac 100644 --- a/src/components/chart/statistics-chart.ts +++ b/src/components/chart/statistics-chart.ts @@ -287,7 +287,7 @@ export class StatisticsChart extends LitElement { }, grid: { ...(this.hideLegend ? { top: this.unit ? 30 : 5 } : {}), // undefined is the same as 0 - left: 20, + left: 5, right: 1, bottom: 0, containLabel: true,