From 160b41b16188b9c0db1e0693bf234565d98c789d Mon Sep 17 00:00:00 2001 From: chu eun ju Date: Fri, 12 Dec 2025 13:20:37 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B0=A8=ED=8A=B8=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_components/normal-distribution-chart.tsx | 27 +++++++++---------- frontend/src/app/dashboard/page.tsx | 6 ++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/frontend/src/app/cow/[cowNo]/genome/_components/normal-distribution-chart.tsx b/frontend/src/app/cow/[cowNo]/genome/_components/normal-distribution-chart.tsx index 40866de..e2cf88a 100644 --- a/frontend/src/app/cow/[cowNo]/genome/_components/normal-distribution-chart.tsx +++ b/frontend/src/app/cow/[cowNo]/genome/_components/normal-distribution-chart.tsx @@ -346,34 +346,32 @@ export function NormalDistributionChart({ // 히스토그램 데이터 생성 (내 개체 중심, 정규분포 곡선) const histogramData = useMemo(() => { - // X축 범위에 맞게 표준편차 조정 (범위의 약 1/3) + // X축 범위에 맞게 표준편차 조정 (범위의 약 1/4) const range = xAxisConfig.max - xAxisConfig.min - const std = range / 4 // 범위에 비례한 표준편차 + const std = range / 4 - // 정규분포 PDF 계산 함수 + // 정규분포 PDF 계산 함수 (0~1 범위로 정규화) const normalPDF = (x: number, mean: number = 0) => { - const coefficient = 1 / (std * Math.sqrt(2 * Math.PI)) const exponent = -Math.pow(x - mean, 2) / (2 * Math.pow(std, 2)) - return coefficient * Math.exp(exponent) * 100 // % 단위로 스케일 + return Math.exp(exponent) // 0~1 범위 } const bins = [] - const step = 0.05 - for (let x = xAxisConfig.min; x <= xAxisConfig.max; x += step) { + const stepSize = range / 100 // 100개의 점으로 부드러운 곡선 + for (let x = xAxisConfig.min; x <= xAxisConfig.max; x += stepSize) { + const pdfValue = normalPDF(x) * 40 // 최대 40%로 스케일링 bins.push({ midPoint: x, - regionPercent: normalPDF(x), - percent: normalPDF(x) + regionPercent: pdfValue, + percent: pdfValue }) } return bins }, [xAxisConfig]) - // 최대 % (Y축 범위용) - const maxPercent = useMemo(() => { - return Math.max(...histogramData.map(d => d.regionPercent)) - }, [histogramData]) + // 최대 % (Y축 범위용) - 항상 40으로 고정 + const maxPercent = 40 return ( @@ -716,7 +714,8 @@ export function NormalDistributionChart({ axisLine={{ stroke: '#cbd5e1', strokeWidth: 1 }} tickLine={false} tick={{ fontSize: isMobileView ? 10 : 11, fill: '#64748b' }} - width={isMobileView ? 30 : 40} + width={isMobileView ? 35 : 45} + domain={[0, Math.ceil(maxPercent)]} tickFormatter={(value) => `${Math.round(value)}%`} /> diff --git a/frontend/src/app/dashboard/page.tsx b/frontend/src/app/dashboard/page.tsx index 1efbbda..66bf01b 100644 --- a/frontend/src/app/dashboard/page.tsx +++ b/frontend/src/app/dashboard/page.tsx @@ -669,7 +669,7 @@ export default function DashboardPage() { filter="drop-shadow(0 4px 6px rgba(31, 58, 143, 0.3))" /> - 우리농가 + 우리농가평균 {originalFarmScore >= 0 ? '+' : ''}{originalFarmScore.toFixed(2)} @@ -678,9 +678,9 @@ export default function DashboardPage() { {/* 보은군 평균 라벨 */} - + - 보은군 {originalRegionScore >= 0 ? '+' : ''}{originalRegionScore.toFixed(2)} + 보은군평균 {originalRegionScore >= 0 ? '+' : ''}{originalRegionScore.toFixed(2)} {/* 차이 화살표 또는 동일 표시 */}