From 97aab7cae474bcf2cd4cc03b01c8f246d6c521c8 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Thu, 22 May 2025 17:47:44 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=B0=ED=95=A8=EC=88=98=EC=A0=95=20-=20,?= =?UTF-8?q?=EA=B0=80=20=EC=9E=88=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20number=20?= =?UTF-8?q?nan=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0,=20=EB=B0=94=20?= =?UTF-8?q?=EC=B0=A8=ED=8A=B8=20fieldText=EC=9C=84=EC=B9=98=20=EC=A1=B0?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/chart/BarChart.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index b75bf373c..cdc88075b 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -76,7 +76,15 @@ const CustomLegend = (props: any) => { export default function Chart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) { const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"]; + const getMaxValue = (data: any[], keyPrefix: string) => { + return Math.max(...data.map(item => + Object.keys(item) + .filter(key => key.includes(keyPrefix)) + .map(key => item[key]) + ).flat()); + }; + const barMaxValue = getMaxValue(chartData, 'barVal'); return ( <> {chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( @@ -102,7 +110,8 @@ export default function Chart({chartConfig=undefined, chartData=[], chartTitle=' axisLine={true} fontSize={12} fontWeight={500} - label={yFieldText ? { value: yFieldText, className:"text-[13px] foont-bold", position: 'top', textAnchor: 'middle', offset: 20 } : undefined} + domain={[0, Math.ceil(barMaxValue * 1)]} + label={yFieldText ? { value: yFieldText, className:"text-[13px] font-bold", position: 'insideLeft', angle: -90, offset: 20 } : undefined} /> }/> {chartData && chartData.length > 0 && (