From a23b80431cf15bcd09933a6f5ee1a67cd9701fb2 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 14 Jul 2025 14:25:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=84=EB=84=9B=EB=B0=94=20=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8=20=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/DoughnutChart.tsx | 56 ++++--------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/packages/common/business_components/src/ui/chart/DoughnutChart.tsx b/packages/common/business_components/src/ui/chart/DoughnutChart.tsx index 99395267a..3dd14e5b7 100644 --- a/packages/common/business_components/src/ui/chart/DoughnutChart.tsx +++ b/packages/common/business_components/src/ui/chart/DoughnutChart.tsx @@ -6,22 +6,13 @@ import { Card, CardContent } from "./lib/card"; -import { ChartContainer, ChartTooltip } from "./lib/chart"; +import { ChartContainer, ChartTooltip, type ChartConfig } from "./lib/chart"; type ChartDataItem = { label: string; val: number; }; -type ChartConfigItem = { - label: string; - fill: string; -}; - -type ChartConfig = { - [key: string]: ChartConfigItem; -}; - type TooltipPayloadItem = { name: string; value: number; @@ -47,20 +38,6 @@ type LegendProps = { payload?: LegendEntry[]; }; -/** 차트 기본 스타일 */ -/* -const customStyles = { - legendContainer: { - display: "flex", - justifyContent: "center", - gap: "20px", - fontSize: "9px", - fontWeight: "bold", - marginTop: "10px", - } as CSSProperties, -}; -*/ - /** 차트 기본 스타일 (라인차트와 동일하게) */ const customStyles = { legendContainer: { @@ -99,25 +76,6 @@ const CustomTooltip = ({ active, payload, label }: { return null; }; -// 커스텀 범례 -/* -const CustomLegend = (props: LegendProps) => { - const { payload } = props; - if (!payload) return null; - - return ( -
- {payload.map((entry: LegendEntry, index: number) => ( -
-
- {entry.value} -
- ))} -
- ); -}; -*/ - const CustomLegend = (props: LegendProps) => { const { payload } = props; if (!payload) return null; @@ -154,14 +112,20 @@ const CustomLegend = (props: LegendProps) => { }; export default function DoughnutChart(props: { - chartConfig: any; + chartConfig: ChartConfig; chartData: ChartDataItem[] | undefined; chartTitle: string }) { const legendData = props.chartData?.map(item => ({ value: item.label, - fill: props.chartConfig?.[item.label]?.fill || 'blue', + fill: props.chartConfig?.[item.label]?.color || 'blue', + payload: { + label: item.label, + val: item.val, + fill: props.chartConfig?.[item.label]?.color || 'blue' + } })) ?? []; + return ( @@ -183,7 +147,7 @@ export default function DoughnutChart(props: { ({ ...item, - fill: props.chartConfig[item.label]?.fill || 'blue' + fill: props.chartConfig[item.label]?.color || 'blue' }))} dataKey="val" nameKey="label"