차트 수정 반영

This commit is contained in:
2025-12-12 13:20:37 +09:00
parent 0e6b06f9ca
commit 160b41b161
2 changed files with 16 additions and 17 deletions

View File

@@ -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)}%`}
/>

View File

@@ -669,7 +669,7 @@ export default function DashboardPage() {
filter="drop-shadow(0 4px 6px rgba(31, 58, 143, 0.3))"
/>
<text x={clampedFarmX} y={chartTop - 18} textAnchor="middle" fill="white" fontSize={11} fontWeight={500}>
</text>
<text x={clampedFarmX} y={chartTop - 2} textAnchor="middle" fill="white" fontSize={16} fontWeight={800}>
{originalFarmScore >= 0 ? '+' : ''}{originalFarmScore.toFixed(2)}
@@ -678,9 +678,9 @@ export default function DashboardPage() {
<line x1={clampedFarmX} y1={chartTop + 4} x2={farmX} y2={chartTop + 20} stroke="#1F3A8F" strokeWidth={2} />
{/* 보은군 평균 라벨 */}
<rect x={regionX - 45} y={chartBottom - 50} width={90} height={28} rx={6} fill="#64748b" />
<rect x={regionX - 50} y={chartBottom - 50} width={100} height={28} rx={6} fill="#64748b" />
<text x={regionX} y={chartBottom - 32} textAnchor="middle" fill="white" fontSize={13} fontWeight={700}>
{originalRegionScore >= 0 ? '+' : ''}{originalRegionScore.toFixed(2)}
{originalRegionScore >= 0 ? '+' : ''}{originalRegionScore.toFixed(2)}
</text>
{/* 차이 화살표 또는 동일 표시 */}