import type { DsProps } from './props'; import * as React from 'react'; import { ResponsiveContainer } from 'recharts'; import { cn } from '@/lib/utils'; import { Surface } from '@/components/ds/Surface'; import { SectionHeader } from '@/components/ds/SectionHeader'; import { EmptyState } from '@/components/ds/EmptyState'; import { SkeletonChart } from '@/components/ds/Skeleton'; import { BarChart3 } from 'lucide-react'; /** * The chart palette. Recharts needs literal colours, not Tailwind classes, so * the brand values are mirrored here — this array is the only place a chart * should get a colour from. */ export const CHART_COLORS = ['#0838E0', '#F9E547', '#333F48', '#F8E08E', '#D1E0D7', '#062BAF']; export const CHART_TONES = { brand: '#0838E0', brandDark: '#062BAF', accent: '#F9E547', accentPale: '#F8E08E', navy: '#333F48', mint: '#D1E0D7', grid: 'hsl(150 8% 87%)', axis: 'hsl(220 9% 64%)', }; /** Shared axis props so every chart's ticks match. */ export const AXIS_PROPS = { stroke: CHART_TONES.axis, tick: { fontSize: 11, fill: CHART_TONES.axis }, tickLine: false, axisLine: false, }; /** * A tooltip matching the design system's surfaces. Recharts' default is a plain * white box that ignores the token set. */ /** @param {any} props */ export function ChartTooltip({ active, payload, label, valueFormatter, labelFormatter }: DsProps) { if (!active || !payload?.length) return null; return (
{labelFormatter ? labelFormatter(label) : label}
)}