From f906d16ebacec5511aa590993fb382f3590807ed Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 9 May 2025 14:05:08 -0600 Subject: [PATCH] fix broken measure --- web/src/lib/canvas.ts | 2 +- .../messageAutoChartHandler/createDefaultTableColumnWidths.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/lib/canvas.ts b/web/src/lib/canvas.ts index dd393caaa..d9494cf6f 100644 --- a/web/src/lib/canvas.ts +++ b/web/src/lib/canvas.ts @@ -14,7 +14,7 @@ const getCanvasContext = () => { export const measureTextWidth = memoize( (text: string | number, font: any = {}) => { if (!isServer) { - const { fontSize, fontFamily = 'sans-serif', fontWeight, fontStyle, fontVariant } = font; + const { fontSize, fontFamily = 'Roobert_Pro', fontWeight, fontStyle, fontVariant } = font; const ctx = getCanvasContext(); // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/font ctx.font = [fontStyle, fontWeight, fontVariant, `${fontSize || 13.6}px`, fontFamily].join( diff --git a/web/src/lib/metrics/messageAutoChartHandler/createDefaultTableColumnWidths.ts b/web/src/lib/metrics/messageAutoChartHandler/createDefaultTableColumnWidths.ts index 9757f95e3..fa735b90e 100644 --- a/web/src/lib/metrics/messageAutoChartHandler/createDefaultTableColumnWidths.ts +++ b/web/src/lib/metrics/messageAutoChartHandler/createDefaultTableColumnWidths.ts @@ -34,7 +34,7 @@ const getDefaultColumnWidth = ( const longestString = rows.reduce((acc, curr) => { const currString = cellFormat(curr[field], field); if (!currString) return acc; - return acc.length > currString.length ? acc : currString; + return String(acc).length > String(currString).length ? acc : currString; }, headerString); const longestWidth = measureTextWidth(longestString).width + OFFSET; return clamp(longestWidth, MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH);