From 104a7b007982c3b13b5790dc17de38b997d602ea Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Wed, 12 Mar 2025 11:02:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B0=A8=ED=8A=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A0=95=EC=A4=91,=20=EB=9D=BC=EC=9D=B8=EB=B0=94=20=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/BarChart.tsx | 4 +- .../src/ui/chart/DoughnutChart.tsx | 3 +- .../src/ui/chart/LineBarChart.tsx | 101 ++++++++++++++++++ .../src/ui/chart/LineChart.tsx | 4 +- .../src/ui/chart/index.tsx | 36 ++++--- 5 files changed, 125 insertions(+), 23 deletions(-) create mode 100644 packages/common/business_components/src/ui/chart/LineBarChart.tsx diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index 98d759f09..96dfab634 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -12,11 +12,11 @@ import { } from "./lib/chart"; import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"; -export default function Chart(props: { chartStyle: CSSProperties | undefined; chartConfig: ChartConfig; chartData: any[] | undefined; }) { +export default function Chart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; }) { return ( - + { +export default (props: { chartConfig: ChartConfig; chartData: never[] | undefined; }) =>{ return ( { + 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) => ( +
+
+ {entry.value} +
+ ))} +
+ ); +}; + +export default function LineBarchart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; }) { + return ( + + + + + + + {/* 왼쪽 Y축: lineVal (정상) */} + + {/* 오른쪽 Y축: barVal (위에서 아래로 반전) */} + + } /> + + {/* 바 차트 (오른쪽 Y축 사용, 위에서 아래로) */} + + {/* 라인 차트 (왼쪽 Y축 사용) */} + + + + + + ) +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index 7cddf66d1..547a29c83 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -12,11 +12,11 @@ import { } from "./lib/chart"; import { CartesianGrid, Line, LineChart, XAxis } from "recharts"; -export default function Linechart(props: { chartStyle: CSSProperties | undefined; chartConfig: ChartConfig; chartData: any[] | undefined; }) { +export default function Linechart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; }) { return ( - + - + ); } else if( props.chartForm == CHART_FORM.DN ){ return (
- +
); + } else if (props.chartForm == CHART_FORM.LINEBAR){ + return ( +
+ + +
+ ); } } -export {MainChart}; +export { MainChart }; // eslint-disable-next-line react-refresh/only-export-components -export {CHART_FORM}; -export type {ChartConfig}; \ No newline at end of file + export { CHART_FORM }; + export type { ChartConfig };