import React from 'react'; import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { formatNumber } from '../../utils/format.ts'; export type PopulationPoint = { date: string; population: number; chickenCount?: number; }; type Props = { data: PopulationPoint[]; title?: string; }; function yTick(value: number): string { if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}jt`; if (value >= 1_000) return `${Math.round(value / 1_000)}rb`; return `${value}`; } const PopulationTrendChart: React.FC = ({ data, title = 'Tren Populasi' }) => { if (!data || data.length === 0) { return (

{title}

Tidak ada data tersedia

); } return (

{title}

{/* Legend: explicit color explanation */}
Populasi (Stock Akhir Manual) Chicken Counting (IOT)
{ const num = Number(value ?? 0); return [num === 0 ? '0' : formatNumber(num, 0), name]; }} labelStyle={{ fontWeight: 600, marginBottom: '4px' }} />

Garis merah = populasi hasil perhitungan manual (stock akhir), garis biru = hasil hitung otomatis sensor IOT. Semakin berdekatan kedua garis, semakin akurat hitungan IOT.

); }; export default PopulationTrendChart;