'use client'; /** * TokenTrendChart — Recharts LineChart showing daily token issuance counts. * * This component is designed to be lazy-loaded via `next/dynamic`. Do NOT * import it directly from a page; use dynamic(() => import('./TokenTrendChart')) * so that recharts stays out of the main bundle. * * @module components/charts/TokenTrendChart */ import React from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from 'recharts'; /** A single data point for the token trend line chart. */ export interface TokenTrendDataPoint { /** ISO 8601 date string (e.g. "2026-03-01"). */ date: string; /** Number of tokens issued on this date. */ count: number; } /** Props for the TokenTrendChart component. */ export interface TokenTrendChartProps { /** Array of daily token issuance data points, sorted ascending by date. */ data: TokenTrendDataPoint[]; } /** * Formats an ISO date string as a short label (e.g. "Mar 1"). * * @param dateStr - ISO 8601 date string * @returns Formatted short date label */ function formatDateLabel(dateStr: string): string { const d = new Date(dateStr); return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); } /** * Renders a responsive line chart of daily token issuance counts using recharts. * * @param props - TokenTrendChartProps * @returns JSX element */ export default function TokenTrendChart({ data, }: TokenTrendChartProps): React.ReactElement { return ( [value.toLocaleString(), 'Tokens issued']} labelFormatter={(label: string) => formatDateLabel(label)} contentStyle={{ borderRadius: '8px', border: '1px solid #e2e8f0', fontSize: '13px', }} /> ); }