From 882a5f046a7862a87fb548a45000d7abdebca488 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 31 Mar 2026 14:46:50 +0900 Subject: [PATCH] =?UTF-8?q?260331=5F05=5FENH:=20=EC=B0=A8=ED=8A=B8?= =?UTF-8?q?=EC=97=90=20=EC=82=AC=EB=A1=80=EC=88=98=20=ED=9D=98=EB=9F=AC?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EA=B0=80=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/lg-dashboard.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/lg-dashboard.ts b/src/lib/lg-dashboard.ts index 6130998..a228993 100644 --- a/src/lib/lg-dashboard.ts +++ b/src/lib/lg-dashboard.ts @@ -192,6 +192,9 @@ export function buildOverlayBarData + excludeRowLabels.some((el) => label.includes(el)); + type Opts = { /** 기본: ["사례수", "gap"] 제외 */ excludeRowLabels?: string[]; @@ -210,25 +213,22 @@ export function buildYearSeriesChartData(rows: BannerRow[], opts: Opts = {}): Ch const years = Array.from(new Set(rows.map((r) => r.year))).sort((a, b) => Number(a) - Number(b)); - // rowLabel 순서: 첫 연도 기준으로 고정(없으면 전체 unique) const baseYear = years[0]; const baseLabels = rows - .filter((r) => r.year === baseYear) - .map((r) => r.rowLabel) - .filter((l) => !excludeRowLabels.includes(l)); + .filter((r) => r.year === baseYear) + .map((r) => r.rowLabel) + .filter((l) => !shouldExcludeLabel(excludeRowLabels, l)); const labels = baseLabels.length > 0 ? baseLabels - : Array.from( - new Set(rows.map((r) => r.rowLabel).filter((l) => !excludeRowLabels.includes(l))) - ); + : Array.from(new Set(rows.map((r) => r.rowLabel).filter((l) => !shouldExcludeLabel(excludeRowLabels, l)))); - // 빠른 조회용: year -> (rowLabel -> total) const map = new Map>(); for (const y of years) map.set(y, new Map()); + for (const r of rows) { - if (excludeRowLabels.includes(r.rowLabel)) continue; + if (shouldExcludeLabel(excludeRowLabels, r.rowLabel)) continue; map.get(r.year)?.set(r.rowLabel, Number(r.total ?? 0)); } @@ -237,7 +237,7 @@ export function buildYearSeriesChartData(rows: BannerRow[], opts: Opts = {}): Ch series: years.map((y) => ({ name: yearLabel(y), data: labels.map((lbl) => map.get(y)?.get(lbl) ?? null), - ...(splitStackByYear ? { stack: String(y) } : {}), // 같은 stack이면 "연도끼리 스택"되어버리니 방지용 + ...(splitStackByYear ? { stack: String(y) } : {}), })), }; } @@ -258,13 +258,13 @@ export function buildRowLabelSeriesChartData( const baseRowLabels = rows .filter((r) => r.year === baseYear) .map((r) => r.rowLabel) - .filter((l) => !excludeRowLabels.includes(l)); + .filter((l) => !shouldExcludeLabel(excludeRowLabels, l)); const rowLabels = baseRowLabels.length > 0 ? baseRowLabels : Array.from( - new Set(rows.map((r) => r.rowLabel).filter((l) => !excludeRowLabels.includes(l))) + new Set(rows.map((r) => r.rowLabel).filter((l) => !shouldExcludeLabel(excludeRowLabels, l))) ); // (year -> (rowLabel -> total)) 맵 @@ -272,7 +272,7 @@ export function buildRowLabelSeriesChartData( for (const y of years) valueMap.set(y, new Map()); for (const r of rows) { - if (excludeRowLabels.includes(r.rowLabel)) continue; + if (shouldExcludeLabel(excludeRowLabels, r.rowLabel)) continue; valueMap.get(r.year)!.set(r.rowLabel, Number(r.total ?? 0)); }