Fix label truncated timeline chart (#24077)

This commit is contained in:
Bram Kragten 2025-02-05 12:47:39 +01:00
parent 4a94cfc05b
commit 6efe237639
2 changed files with 5 additions and 2 deletions

View File

@ -214,7 +214,7 @@ export class StateHistoryChartTimeline extends LitElement {
}, },
axisLabel: { axisLabel: {
show: showNames, show: showNames,
width: labelWidth - labelMargin, width: labelWidth,
overflow: "truncate", overflow: "truncate",
margin: labelMargin, margin: labelMargin,
formatter: (id: string) => { formatter: (id: string) => {

View File

@ -21,5 +21,8 @@ export function measureTextWidth(
} }
context.font = `${fontSize}px ${fontFamily}`; context.font = `${fontSize}px ${fontFamily}`;
return Math.ceil(context.measureText(text).width); const textMetrics = context.measureText(text);
return Math.ceil(
textMetrics.actualBoundingBoxRight + textMetrics.actualBoundingBoxLeft
);
} }