From 1d20055f7d3e538df1cbe64a9407f4f825596ad8 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 19 Aug 2026 15:49:36 +0900 Subject: [PATCH] =?UTF-8?q?260819=5F02=5FENH:=20=EC=B0=A8=ED=8A=B8=20?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EB=B8=94=20=EA=B0=80=EB=B3=80=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88=20=EB=8B=A8=EC=96=B4=20=EA=B8=B0=EB=B0=98?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=B2=98=EB=A6=AC=EB=90=98=EA=B2=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/[waveCd]/[partCd]/page.tsx | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx index 17f4111..87f7ce7 100644 --- a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx +++ b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx @@ -62,6 +62,35 @@ function buildHiddenCategoryNote(group: ResultGroup): string | null { // 고정값을 쓰면 화면이 넓을 때는 불필요하게 줄바꿈되고, 좁을 때는 라벨이 겹치는 문제가 생긴다. const MIN_AXIS_LABEL_WIDTH = 48; +// echarts axisLabel의 overflow:'break'는 한글을 알파벳 "단어"로 인식하지 못해 음절 단위로 강제 개행한다 +// (zrender wrapText의 isWordBreakChar가 비알파벳 문자를 전부 break 지점으로 취급함). +// 그래서 공백 기준으로 단어를 유지한 채 줄바꿈 문자열을 직접 만들고, 단어 하나가 라인 폭을 넘을 때만 강제로 자른다. +function wrapLabelByWord(value: string, maxWidth: number, charWidth: number) { + const maxChars = Math.max(1, Math.floor(maxWidth / charWidth)); + const words = value.split(" "); + const lines: string[] = []; + let currentLine = ""; + + for (const word of words) { + const candidate = currentLine ? `${currentLine} ${word}` : word; + + if (candidate.length > maxChars && currentLine) { + lines.push(currentLine); + currentLine = word; + } else { + currentLine = candidate; + } + + while (currentLine.length > maxChars) { + lines.push(currentLine.slice(0, maxChars)); + currentLine = currentLine.slice(maxChars); + } + } + if (currentLine) lines.push(currentLine); + + return lines.join("\n"); +} + function ResultGroupChart({ group }: { group: ResultGroup }) { const chartData = toChartData(group.categories, group.series); const hasChartData = chartData.categories.length > 0 && chartData.series.length > 0; @@ -108,7 +137,9 @@ function ResultGroupChart({ group }: { group: ResultGroup }) { axisLabel: { fontSize: CHART_FONT_SIZE, interval: 0, - ...(axisLabelWidth ? { width: axisLabelWidth, overflow: "break" as const } : {}), + ...(axisLabelWidth + ? { formatter: (value: string) => wrapLabelByWord(value, axisLabelWidth, CHART_FONT_SIZE) } + : {}), }, }} yAxis={{ min: 0, max: 100, interval: 25, axisLabel: { fontSize: CHART_FONT_SIZE } }}