import {Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts'; import type {CrawlerDaily} from '@/api'; import {PURPOSE_COLOR, PURPOSES, purposeLabel} from './labels'; import {daysBetween} from './range'; // recharts 는 행 하나를 {day, search: n, training: n, …} 로 받는다. type Row = Record; function pivot(daily: CrawlerDaily[], from: string, to: string): Row[] { const rows = new Map(daysBetween(from, to).map((day) => [day, {day}])); for (const {day, purpose, hits} of daily) { const row = rows.get(day); if (row) row[purpose] = Number(row[purpose] ?? 0) + hits; } return [...rows.values()]; } /** recharts 를 이 파일에만 둔다 — CrawlerStatsPanel 이 lazy() 로 불러 사장님 화면 번들에 안 들어간다. */ export default function CrawlerDailyChart({daily, from, to}: {daily: CrawlerDaily[]; from: string; to: string}) { return ( day.slice(5)} fontSize={11} /> [value, purposeLabel(String(name))]} /> purposeLabel(String(value))} wrapperStyle={{fontSize: 11}} /> {PURPOSES.map((purpose) => ( ))} ); }