From bcf4b258b2d7ef05a33c731687487a29eabde87f Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 25 Aug 2026 16:43:10 +0900 Subject: [PATCH] =?UTF-8?q?260825=5F04=5FENH:=20=EC=B0=A8=ED=8A=B8=20?= =?UTF-8?q?=EC=83=89=EC=83=81=EC=9D=84=20t=5Fsurvey=20=EC=A2=85=EC=86=8D?= =?UTF-8?q?=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20?= =?UTF-8?q?=ED=9B=84=EC=86=8D=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/[waveCd]/[partCd]/page.tsx | 53 ++++++++++------- src/lib/chart-utils.ts | 57 ++++++++++++++----- src/types/wave.ts | 12 +++- 3 files changed, 85 insertions(+), 37 deletions(-) diff --git a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx index c868dee..86c7fe0 100644 --- a/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx +++ b/src/app/(pages)/(main)/dashboard/[waveCd]/[partCd]/page.tsx @@ -18,7 +18,7 @@ import { SUBITEM_NEGATIVE_COLOR, } from "@/const/epolicy-dash.const"; import { cn } from "@/lib/utils"; -import { getGapPoints, getHighlightedIndexes, toChartData } from "@/lib/chart-utils"; +import { getGapPoints, getHighlightedIndexes, isNegativeCategory, 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"; @@ -110,8 +110,11 @@ function wrapLabelByWord(value: string, maxWidth: number, charWidth: number) { return lines.join("\n"); } -function ResultGroupChart({ group }: { group: ResultGroup }) { +function ResultGroupChart({ group, item }: { group: ResultGroup; item: Item }) { const chartData = toChartData(group.categories, group.series); + const visibleCategories = group.categories.filter((category) => category.chartVisible); + const negativeMode = group.subItem === null ? item.negativeMode : group.subItem.negativeMode; + const negativeOrder = group.subItem === null ? item.negativeOrder : group.subItem.negativeOrder; const hasChartData = chartData.categories.length > 0 && chartData.series.length > 0; const chartWrapperRef = useRef(null); const [axisLabelWidth, setAxisLabelWidth] = useState(); @@ -137,18 +140,29 @@ function ResultGroupChart({ group }: { group: ResultGroup }) {
{ - const highlightedIndexes = item.chartHighlightMode ? getHighlightedIndexes(group.categories, item) : []; - const gapPoints = getGapPoints(group.categories, item); + series={chartData.series.map((series) => { + const highlightedIndexes = series.chartHighlightMode + ? getHighlightedIndexes(group.categories, series) + : []; + const gapPoints = getGapPoints(group.categories, series); 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, + name: seriesLegendName(series.label, series.baseCount), + data: series.values.map((value, index) => { + const category = visibleCategories[index]; + const isNegative = category ? isNegativeCategory(negativeMode, negativeOrder, category) : false; + const isHighlighted = highlightedIndexes.includes(index); + const color = isNegative + ? isHighlighted + ? series.negativeHighlightColor + : series.negativeColor + : isHighlighted + ? series.highlightColor + : series.color; + + return { value: round1(value), itemStyle: { color } }; + }), + color: negativeMode === "NEGATIVE" ? series.negativeColor : series.color, option: { label: { show: true, @@ -166,7 +180,7 @@ function ResultGroupChart({ group }: { group: ResultGroup }) { show: true, position: "top", // 막대 자체의 값 라벨(position:"top")과 겹치지 않도록 그 위로 띄운다. - distance: 15, + distance: 30, color: CHART_GAP_MARKER_TEXT_COLOR, backgroundColor: CHART_GAP_MARKER_BG_COLOR, borderRadius: 20, @@ -176,12 +190,9 @@ function ResultGroupChart({ group }: { group: ResultGroup }) { 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], + // ALL: 각 현재 막대 위치. LAST_VISIBLE: 마지막 표시 막대 위치에 표시한다. + data: gapPoints.map(({ index, value, gap }) => ({ + coord: [index, value], value: gap, })), }, @@ -286,7 +297,7 @@ function ItemCard({ item }: { item: Item }) {
{item.resultGroups.map((group, index) => { const isActive = index === activeGroupIndex; - const isNegativeSubItem = group.subItem?.partItemSubCd === 2; + const isNegativeSubItem = group.subItem?.negativeMode === "NEGATIVE"; return (