From 392ccefb16ca568e128772abf175b3670964e193 Mon Sep 17 00:00:00 2001 From: jsyang Date: Tue, 26 Aug 2025 17:47:51 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9D=BC=EC=9D=B8=EB=B0=94=20=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8property=20=EC=B6=94=EA=B0=80=20(setXAxisYearTick=20-?= =?UTF-8?q?=20=EB=82=A0=EC=A7=9C=20x=EC=B6=95=EC=9D=BC=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=20(=EB=85=84=EB=8F=84-=EC=9B=94)=EB=B3=84=EB=A1=9C=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EC=A3=BC=EB=8A=94=20=EC=86=8D=EC=84=B1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/LineBarChart.tsx | 28 +++++++++++++++++-- .../src/ui/chart/index.tsx | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/common/business_components/src/ui/chart/LineBarChart.tsx b/packages/common/business_components/src/ui/chart/LineBarChart.tsx index d81d6e2c8..9f9a4feec 100644 --- a/packages/common/business_components/src/ui/chart/LineBarChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineBarChart.tsx @@ -6,6 +6,7 @@ import { type ChartConfig } from "./lib/chart"; import type { ContentType } from "recharts/types/component/DefaultLegendContent"; +import type { set } from "date-fns"; // 툴크 커스텀 css /** 차트 기본 스타일 */ @@ -29,6 +30,7 @@ type LineBarChartProps = { yFieldText?: string | undefined; yFieldText2?: string | undefined; showLegend?: boolean; + setXAxisYearTick?: boolean; } type LegendEntry = { @@ -86,7 +88,8 @@ export default function LineBarchart({ graphSize = 40, yFieldText, yFieldText2, - showLegend = true + showLegend = true, + setXAxisYearTick = false }: LineBarChartProps) { if (!chartData || chartData.length === 0) { return
데이터가 없습니다.
; @@ -105,6 +108,24 @@ export default function LineBarchart({ const lineMaxValue = getMaxValue(chartData, 'lineVal'); const barMaxValue = getMaxValue(chartData, 'barVal'); + const getTicks = (data : any []) => { + const monthSet = new Set(); + const rtnData : string[] = []; + for(const item of data){ + const month = String(item.label).slice(0,7); + if(!monthSet.has(month)){ + monthSet.add(month); + rtnData.push(item.label); + } + } + return rtnData; + } + + let monthTicks : string[] = []; + if(setXAxisYearTick){ + monthTicks = getTicks(chartData); + } + return (
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( @@ -121,7 +142,10 @@ export default function LineBarchart({ margin={{ top: 5, right: 30, left: 20, bottom: 5 }} > - + {setXAxisYearTick? + value.slice(0,7)} fontSize="8px" fontWeight="bold"/> : + + } {/* 왼쪽 Y축: lineVal */} {yFieldText && + ); } else if (props.chartForm == CHART_FORM.LINEBAR2){ return (