Workaround for chart size bug in editor preview (#24040)

This commit is contained in:
Petar Petrov 2025-02-03 16:59:43 +02:00 committed by Bram Kragten
parent af35b15400
commit 6eb43a7d61
2 changed files with 3 additions and 2 deletions

View File

@ -267,7 +267,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", {

View File

@ -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,