import Dn from '../Dn' import type { WeeklyActivity } from '../../lib/database.types' interface Props { data: WeeklyActivity[] // Which metric to visualize as the bar: 'cups' or 'co2_kg'. metric?: 'cups' | 'co2_kg' } // E-Ink horizontal bar chart. No external libs, no animations. // Each row is one week. Bar width scales to the real max in the dataset // (falls back to 1 only when every value is zero, to avoid divide-by-zero). export default function WeeklyChart({ data, metric = 'cups' }: Props) { const values = data.map((d) => (metric === 'cups' ? d.cups : d.co2_kg)) const realMax = Math.max(...values, 0) const max = realMax > 0 ? realMax : 1 return (
{formatWeekLabel(row.week_start)}
{metric === 'cups' ? value :
시민 {row.active_citizens}
)}