import { Area, CartesianGrid, ComposedChart, Legend, Line,
ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
import { ChartActiveDot, ChartLegendContent, ChartTooltipContent, selectEvenlySpacedItems } from "@/components/application/charts/charts-base";
// data: { month, desktop, mobile, tablet }[] — 36 months, so the
// sampler thins the axis to seven ticks. The wash under the lead
// series is a <linearGradient> in <defs>, its color at 8% fading to 0.
<ResponsiveContainer width="100%" height={240}>
<ComposedChart data={data}>
<CartesianGrid vertical={false} className="stroke-border-secondary" />
<XAxis dataKey="month" tickLine={false} axisLine={false}
ticks={selectEvenlySpacedItems(months, 7)} interval={0}
padding={{ right: 28 }} // keeps the centered end label inside the svg
className="text-tertiary" tick={{ className: "fill-current text-xs" }} />
<YAxis width={40} tickLine={false} axisLine={false}
className="text-tertiary" tick={{ className: "fill-current text-xs" }} />
<Tooltip isAnimationActive={false}
cursor={{ className: "stroke-utility-brand-600", strokeWidth: 2,
strokeLinecap: "round" }} // the sheet's marker cursor
content={<ChartTooltipContent />} />
<Legend verticalAlign="top" align="right"
content={<ChartLegendContent align="right" className="pb-4" />} />
<Area dataKey="desktop" name="Desktop" className="text-utility-brand-600"
stroke="currentColor" strokeWidth={2} fill="url(#wash)" dot={false}
isAnimationActive={false}
activeDot={(dot) => <ChartActiveDot cx={dot.cx} cy={dot.cy} />} />
{/* Mobile and Tablet: the same Line at brand-400 and brand-700 */}
</ComposedChart>
</ResponsiveContainer>