Fix label truncated timeline chart (#24077)

This commit is contained in:
Bram Kragten 2025-02-05 12:47:39 +01:00 committed by GitHub
parent 5a8b1b0fd4
commit 72d208d1ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

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

View File

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