'use client'; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from 'recharts'; export interface PriceAreaChartPoint { period: string; avgPriceM2: number; } interface PriceAreaChartProps { data: PriceAreaChartPoint[]; height?: number; className?: string; } /** * 30-day price area chart using signal colors. * Green fill when latest > first point, red otherwise. */ export function PriceAreaChart({ data, height = 280, className }: PriceAreaChartProps) { const isUp = data.length >= 2 && data[data.length - 1]!.avgPriceM2 >= data[0]!.avgPriceM2; // CSS tokens are stored as raw HSL components (`--signal-up: 142 72% 50%`), // so they must be wrapped in `hsl(...)`. The previous `var(--color-signal-up)` // form referenced a non-existent variable, leaving recharts with `undefined` // and rendering an invisible line/area. const strokeColor = isUp ? 'hsl(var(--signal-up))' : 'hsl(var(--signal-down))'; const fillColor = strokeColor; return (