From 75385bd452d81bf8f87b66ac6f70a7df651972a8 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 25 Aug 2026 14:48:49 +0900 Subject: [PATCH] =?UTF-8?q?260825=5F01=5FENH:=20=EC=B0=A8=ED=8A=B8=20?= =?UTF-8?q?=EB=AC=B8=ED=95=AD=EB=B3=84=20=EC=83=89=EC=83=81=EC=A7=80?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=EC=B0=A8=ED=8A=B8=20=ED=95=98=EC=9D=B4?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=ED=8A=B8=20=EB=AA=A8=EB=93=9C=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9,=20=EB=AC=B8=ED=95=AD=EB=B3=84=20=EC=A0=9C=EB=AA=A9?= =?UTF-8?q?=EA=B3=BC=20=EB=B2=94=EB=A1=80=20=EC=82=AC=EC=9D=B4=EC=97=90=20?= =?UTF-8?q?=EB=AC=B8=ED=95=AD=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=82=BD?= =?UTF-8?q?=EC=9E=85,=20gap=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/[waveCd]/[partCd]/page.tsx | 147 ++++++++++++++---- src/components/layout/KriSidebar.tsx | 4 +- src/const/epolicy-dash.const.ts | 11 +- src/lib/chart-utils.ts | 80 +++++++++- src/types/wave.ts | 17 +- 5 files changed, 220 insertions(+), 39 deletions(-) diff --git a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx index 87f7ce7..26a045c 100644 --- a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx +++ b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx @@ -3,14 +3,22 @@ import { ChevronDown } from "lucide-react"; import { useParams, useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; +import type { CSSProperties } from "react"; import { KriBarChart } from "@/components/chart"; import { AppPageTitle } from "@/components/app-shell/AppPageTitle"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; -import { CHART_BAR_MAX_WIDTH, CHART_FONT_SIZE, CHART_HEIGHT } from "@/const/epolicy-dash.const"; +import { + CHART_BAR_MAX_WIDTH, + CHART_FONT_SIZE, + CHART_GAP_MARKER_BG_COLOR, + CHART_GAP_MARKER_TEXT_COLOR, + CHART_HEIGHT, + SUBITEM_NEGATIVE_COLOR, +} from "@/const/epolicy-dash.const"; import { cn } from "@/lib/utils"; -import { toChartData } from "@/lib/chart-utils"; +import { getGapPoints, getHighlightedIndexes, toChartData } from "@/lib/chart-utils"; import { formatDecimal1, formatThousands, round1 } from "@/lib/format"; import { isSessionInvalid, resolveApiErrorMessage } from "@/lib/api-error-message"; import { usePartDetailQuery } from "@/query/waves"; @@ -26,6 +34,17 @@ function findAudienceColor(item: Item): string | undefined { return undefined; } +// 서브 탭 hover 배경처럼 색상에 알파를 입힌 은은한 톤이 필요한 곳에서 사용한다. +function hexToRgba(hex: string, alpha: number): string { + const normalized = hex.replace("#", ""); + const isShorthand = normalized.length === 3; + const r = parseInt(isShorthand ? normalized[0] + normalized[0] : normalized.slice(0, 2), 16); + const g = parseInt(isShorthand ? normalized[1] + normalized[1] : normalized.slice(2, 4), 16); + const b = parseInt(isShorthand ? normalized[2] + normalized[2] : normalized.slice(4, 6), 16); + if ([r, g, b].some((channel) => Number.isNaN(channel))) return hex; + return `rgba(${r}, ${g}, ${b}, ${alpha})`; +} + function seriesLegendName(label: string, baseCount: number | null) { return baseCount === null ? label : `${label} (N=${formatThousands(baseCount)})`; } @@ -118,19 +137,59 @@ function ResultGroupChart({ group }: { group: ResultGroup }) {
({ - name: seriesLegendName(item.label, item.baseCount), - data: item.values.map(round1), - color: item.color, - option: { - label: { - show: true, - position: "top", - fontSize: CHART_FONT_SIZE, - formatter: (params: { value: number }) => formatDecimal1(params.value), + series={chartData.series.map((item) => { + const highlightedIndexes = item.chartHighlightMode ? getHighlightedIndexes(group.categories, item) : []; + const gapPoints = getGapPoints(group.categories, item); + + return { + name: seriesLegendName(item.label, item.baseCount), + data: item.values.map((value, index) => + highlightedIndexes.includes(index) && item.chartHighlightColor + ? { value: round1(value), itemStyle: { color: item.chartHighlightColor } } + : round1(value), + ), + color: item.color, + option: { + label: { + show: true, + position: "top", + fontSize: CHART_FONT_SIZE, + formatter: (params: { value: number }) => formatDecimal1(params.value), + }, + ...(gapPoints.length + ? { + markPoint: { + // 점 마커 없이, 라운딩된 사각형 배경을 가진 라벨 자체를 도형처럼 사용한다. + symbol: "circle", + symbolSize: 0, + label: { + show: true, + position: "top", + // 막대 자체의 값 라벨(position:"top")과 겹치지 않도록 그 위로 띄운다. + distance: 15, + color: CHART_GAP_MARKER_TEXT_COLOR, + backgroundColor: CHART_GAP_MARKER_BG_COLOR, + borderRadius: 20, + padding: [10, 10, 7, 10], + fontWeight: "bold", + fontSize: CHART_FONT_SIZE, + formatter: ({ value }: { value: number }) => + `${value >= 0 ? "▲" : "▼"} ${formatDecimal1(Math.abs(value))}%p`, + }, + // ALL: 현재 막대 바로 위. LAST_VISIBLE: 직전 막대와의 중간 지점(두 막대 사이)에 표시한다. + data: gapPoints.map(({ index, previousIndex, value, previousValue, gap }) => ({ + coord: + item.chartGapMode === "LAST_VISIBLE" + ? [(index + previousIndex) / 2, Math.max(value, previousValue)] + : [index, value], + value: gap, + })), + }, + } + : {}), }, - }, - }))} + }; + })} legend={{ left: 0, top: 0, textStyle: { fontSize: CHART_FONT_SIZE } }} grid={{ top: 55, right: 25, bottom: 5, left: 0, containLabel: true }} xAxis={{ @@ -195,6 +254,8 @@ function ItemCard({ item }: { item: Item }) { const hasSubItems = item.resultGroups.some((group) => group.subItem !== null); const activeGroup = item.resultGroups[activeGroupIndex] ?? item.resultGroups[0]; const hiddenCategoryNote = activeGroup ? buildHiddenCategoryNote(activeGroup) : null; + // subItem 코멘트가 있으면 그것을 우선 표시하고, 없으면 문항 공통 코멘트로 대체한다. + const activeComment = activeGroup?.subItem?.partItemSubComment || item.comment || null; return (
@@ -217,22 +278,46 @@ function ItemCard({ item }: { item: Item }) {
- {hasSubItems ? ( -
-
- {item.resultGroups.map((group, index) => ( - - ))} + {hasSubItems || activeComment ? ( +
+
+ {activeComment ?

{activeComment}

: null}
+ {hasSubItems ? ( +
+ {item.resultGroups.map((group, index) => { + const isActive = index === activeGroupIndex; + const isNegativeSubItem = group.subItem?.partItemSubCd === 2; + + return ( + + ); + })} +
+ ) : null}
) : null} @@ -247,8 +332,6 @@ function ItemCard({ item }: { item: Item }) { ) : null}
) : null} - - {item.comment ?

{item.comment}

: null}
); } @@ -281,7 +364,7 @@ export default function PartDetailPage() { } return ( -
+
{data.items.map((item) => ( diff --git a/src/components/layout/KriSidebar.tsx b/src/components/layout/KriSidebar.tsx index 9f22a2f..e532699 100644 --- a/src/components/layout/KriSidebar.tsx +++ b/src/components/layout/KriSidebar.tsx @@ -36,7 +36,7 @@ export function KriSidebar({