"use client"; import { Area, AreaChart, Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import type { DailyPoint, GameReportRow, ScrollBucket } from "@/lib/analytics/queries"; /** * Recharts panels for the analytics admin view. Kept as tiny client islands: * the surrounding view (tabs, tables, filters) renders server-side. Colors * are explicit hex values because the Payload admin panel does not define the * frontend chart CSS variables. */ const AXIS_STYLE = { fill: "#a3a3a3", fontSize: 11 } as const; interface TooltipEntry { name?: string | number; value?: string | number; color?: string; } function AdminTooltip({ active, payload, label, labelFormatter, }: { active?: boolean; payload?: TooltipEntry[]; label?: string | number; labelFormatter?: (label: string | number) => string; }) { if (!active || !payload || payload.length === 0) return null; return (

{labelFormatter && label !== undefined ? labelFormatter(label) : label}

{payload.map((entry, index) => (

{entry.name} {entry.value}

))}
); } export function OverviewTrendChart({ series }: { series: DailyPoint[] }) { return (
} cursor={{ stroke: "rgba(255,255,255,0.2)" }} />
); } export function ScrollDistributionChart({ buckets }: { buckets: ScrollBucket[] }) { return (
`Scrolled ${label}` as string} />} cursor={{ fill: "rgba(255,255,255,0.04)" }} />
); } export function GamesBarChart({ rows }: { rows: GameReportRow[] }) { const data = rows.map((row) => ({ name: row.gameKey, sessions: row.sessions })); return (
} cursor={{ fill: "rgba(255,255,255,0.04)" }} />
); }