{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sparkline",
  "title": "Sparkline",
  "description": "A tiny inline area or line chart for showing a trend at a glance.",
  "dependencies": [
    "recharts"
  ],
  "files": [
    {
      "path": "registry/dashboardcn/ui/sparkline.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  Area,\n  AreaChart,\n  AreaRevealShape,\n  Line,\n  LineChart,\n  ResponsiveContainer,\n  type AreaRevealShapeProps,\n} from \"recharts\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface SparklineProps extends React.ComponentProps<\"div\"> {\n  /** Series to plot, oldest first. */\n  data: number[]\n  variant?: \"area\" | \"line\"\n  /** Area fill: a plain gradient, or a dot grid that fades out toward the line. */\n  fill?: \"gradient\" | \"dots\"\n  /** Any CSS color. Defaults to the theme primary. */\n  color?: string\n  curve?: \"monotone\" | \"linear\" | \"step\"\n  strokeWidth?: number\n  /** Animate after hydration and when data changes. Respects reduced motion. */\n  animate?: boolean\n  animationDuration?: number\n}\n\nconst reducedMotionQuery = \"(prefers-reduced-motion: reduce)\"\n\nfunction subscribeToReducedMotion(onChange: () => void) {\n  const query = window.matchMedia(reducedMotionQuery)\n  query.addEventListener(\"change\", onChange)\n  return () => query.removeEventListener(\"change\", onChange)\n}\n\nfunction getReducedMotionSnapshot() {\n  return window.matchMedia(reducedMotionQuery).matches\n}\n\nfunction getReducedMotionServerSnapshot() {\n  return true\n}\n\n/** Area shape that masks the fill to a dot grid while keeping the stroke solid. */\nfunction DotGridAreaShape({\n  maskId,\n  ...props\n}: AreaRevealShapeProps & { maskId: string }) {\n  return (\n    <>\n      <g mask={`url(#${maskId})`}>\n        <AreaRevealShape {...props} stroke=\"none\" />\n      </g>\n      <AreaRevealShape {...props} id={undefined} fill=\"none\" />\n    </>\n  )\n}\n\nfunction Sparkline({\n  data,\n  variant = \"area\",\n  fill = \"gradient\",\n  color = \"var(--primary)\",\n  curve = \"monotone\",\n  strokeWidth = 1.5,\n  animate = true,\n  animationDuration = 500,\n  className,\n  ...props\n}: SparklineProps) {\n  const id = React.useId()\n  const reducedMotion = React.useSyncExternalStore(\n    subscribeToReducedMotion,\n    getReducedMotionSnapshot,\n    getReducedMotionServerSnapshot\n  )\n  const animationActive = animate && !reducedMotion\n  const dots = variant === \"area\" && fill === \"dots\"\n  const points = React.useMemo(() => data.map((y, i) => ({ i, y })), [data])\n  const margin = { top: 2, right: 0, bottom: 0, left: 0 }\n\n  return (\n    <div\n      data-slot=\"sparkline\"\n      aria-hidden=\"true\"\n      className={cn(\"h-10 w-full\", className)}\n      {...props}\n    >\n      <ResponsiveContainer width=\"100%\" height=\"100%\">\n        {variant === \"line\" ? (\n          <LineChart data={points} margin={margin}>\n            <Line\n              type={curve}\n              dataKey=\"y\"\n              stroke={color}\n              strokeWidth={strokeWidth}\n              dot={false}\n              isAnimationActive={animationActive}\n              animationDuration={animationDuration}\n              animationEasing=\"ease-out\"\n            />\n          </LineChart>\n        ) : (\n          <AreaChart data={points} margin={margin}>\n            <defs>\n              <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0%\" stopColor={color} stopOpacity={dots ? 0.08 : 0.3} />\n                <stop offset=\"100%\" stopColor={color} stopOpacity={dots ? 0.9 : 0} />\n              </linearGradient>\n              {dots ? (\n                <>\n                  <pattern\n                    id={`${id}-dots`}\n                    patternUnits=\"userSpaceOnUse\"\n                    width={4}\n                    height={4}\n                  >\n                    <circle cx={2} cy={2} r={0.9} fill=\"#fff\" />\n                  </pattern>\n                  <mask\n                    id={`${id}-mask`}\n                    maskUnits=\"userSpaceOnUse\"\n                    x={0}\n                    y={0}\n                    width=\"100%\"\n                    height=\"100%\"\n                  >\n                    <rect width=\"100%\" height=\"100%\" fill={`url(#${id}-dots)`} />\n                  </mask>\n                </>\n              ) : null}\n            </defs>\n            <Area\n              type={curve}\n              dataKey=\"y\"\n              stroke={color}\n              strokeWidth={strokeWidth}\n              fill={`url(#${id})`}\n              fillOpacity={dots ? 1 : undefined}\n              dot={false}\n              isAnimationActive={animationActive}\n              animationDuration={animationDuration}\n              animationEasing=\"ease-out\"\n              shape={\n                dots\n                  ? (shapeProps: AreaRevealShapeProps) => (\n                      <DotGridAreaShape {...shapeProps} maskId={`${id}-mask`} />\n                    )\n                  : undefined\n              }\n            />\n          </AreaChart>\n        )}\n      </ResponsiveContainer>\n    </div>\n  )\n}\n\nexport { Sparkline }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}