diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index 814e12620..5d4f902e8 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -32,12 +32,43 @@ type BarChartProps = { showLegend?: boolean; } +// 커스텀 툴팁 +const CustomTooltip = ({ + active, + payload, + label +}: { + active?: boolean; + payload?: Array<{ + name: string; + value: number; + color: string; + }>; + label?: string; +}) => { + if (active && payload && payload.length) { + return ( +
+

{label}

+ {payload.map((item, index) => ( +
+ {/* 색상 박스 추가 (범례 색상과 동일) */} +
+ {` ${item.name} : ${item.value}`} +
+ ))} +
+ ); + } + return null; +}; + // 커스텀 범례 (글씨 크기 키우기 + 스타일 추가) const CustomLegend = (props: any) => { const { payload } = props; return (
- {payload.map((entry, index) => ( + {payload.map((entry, index: number) => (
{entry.value} @@ -77,7 +108,7 @@ export default function Chart({chartConfig=undefined, chartData=[], chartTitle=' fontWeight={500} label={yFieldText ? { value: yFieldText, className:"text-[13px] foont-bold", position: 'top', textAnchor: 'middle', offset: 20 } : undefined} /> - }/> + }/> {chartData && chartData.length > 0 && ( Object.keys(chartData[0]) .filter(key => key !== "label") diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index 136034e00..c005efbdf 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -1,16 +1,14 @@ "use client" import type { CSSProperties } from "react"; +import { CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts"; import { Card, CardContent } from "./lib/card"; import { ChartContainer, - ChartTooltip, - ChartTooltipContent, type ChartConfig } from "./lib/chart"; -import { CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts"; /** 차트 기본 스타일 */ const styles = { @@ -41,9 +39,20 @@ const styles = { marginTop: "10px", } as CSSProperties, }; - // 커스텀 툴팁 -const CustomTooltip = ({ active, payload, label }) => { +const CustomTooltip = ({ + active, + payload, + label +}: { + active?: boolean; + payload?: Array<{ + name: string; + value: number; + color: string; + }>; + label?: string; +}) => { if (active && payload && payload.length) { return (