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({