{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sparkline",
  "title": "Sparkline",
  "description": "A tiny inline line for tables and stat cards, drawn as it reaches the middle of the screen, with an optional hatched area and an end dot.",
  "dependencies": [
    "svg-scroll-draw@^2.29.0"
  ],
  "registryDependencies": [
    "https://scrollfx-ui.vercel.app/r/plotter.json",
    "https://scrollfx-ui.vercel.app/r/chart.json"
  ],
  "files": [
    {
      "path": "registry/ui/sparkline.tsx",
      "content": "'use client';\n\n/**\n * sparkline — a tiny line, the size of a word, for tables and stat cards. A\n * pen draws it left to right as it reaches the middle of the screen, over a\n * hatched area if you like, and ends on a dot in the accent colour.\n *\n * Built on svg-scroll-draw (MIT): https://github.com/DhruvilChauahan0210/scrollfx\n * Needs: react, svg-scroll-draw, lib/chart and lib/plotter (installed with it).\n * Styling: Tailwind CSS with shadcn/ui tokens. Size it with `className`\n * (h-8 w-28 by default); it sits inline, on the text's baseline.\n *\n * Its label for screen readers is in the server HTML; the strokes are made in\n * the browser at its size. Reduced motion shows it drawn.\n */\n\nimport { useMemo } from 'react';\nimport 'svg-scroll-draw/no-flash.css';\nimport { ACCENT, PenLayers, circle, curvePath, curvePoints, hatchMarks, linear, useSize, type ChartTrigger, type Curve, type Mark, type Pen, type Pt } from '@/lib/chart';\n\nexport interface SparklineProps {\n  /** The values, left to right. */\n  data?: number[];\n  /** A line alone, or a line over a hatched area. */\n  variant?: 'line' | 'area';\n  /** How the pen joins the points. */\n  curve?: Curve;\n  /** A dot on the last value. */\n  dot?: boolean;\n  /** The line's colour; the hatching is in the ink. */\n  color?: string;\n  /** What it shows, for screen readers. Defaults to the first and last values. */\n  label?: string;\n  /** `scroll`: inked as it rises, done at mid-screen. `view`: played once as it comes into view. */\n  trigger?: ChartTrigger;\n  /** With `view`, how long the line takes, in ms. */\n  duration?: number;\n  className?: string;\n}\n\nconst SAMPLE = [12, 14, 13, 17, 16, 21, 19, 24, 23, 28, 27, 31];\n\nexport function Sparkline({ data = SAMPLE, variant = 'line', curve = 'smooth', dot = true, color = ACCENT, label, trigger = 'scroll', duration = 1200, className = 'h-8 w-28' }: SparklineProps) {\n  const [ref, size] = useSize<HTMLSpanElement>();\n  const lo = Math.min(...data), hi = Math.max(...data);\n\n  const pens = useMemo((): Pen[] | null => {\n    if (!size || data.length < 2) return null;\n    const { w, h } = size;\n    // Room for the pen's width and the end dot, so nothing is clipped.\n    const pad = dot ? 4 : 2;\n    const y = linear(lo, hi === lo ? lo + 1 : hi, h - 2, 2);\n    const pts: Pt[] = data.map((v, i) => [pad / 2 + (i / (data.length - 1)) * (w - pad * 1.5), y(v)]);\n    const fill: Mark[] = variant === 'area'\n      ? hatchMarks([...curvePoints(pts, curve), [pts[pts.length - 1][0], h], [pts[0][0], h]], { angle: 90, gap: 3 }, { opacity: 0.55, width: 0.8, inset: 1.6 })\n      : [];\n    const [ex, ey] = pts[pts.length - 1];\n    return [\n      { marks: fill, from: 1.05, to: 0.7, spread: 2 },\n      { marks: [{ d: curvePath(pts, curve), color, width: 1.6 }], from: 0.82, to: dot ? 0.56 : 0.5 },\n      // The end dot: two turns of the pen, so it reads solid.\n      { marks: dot ? [{ d: circle(ex, ey, 2.3), color, width: 1.5 }, { d: circle(ex, ey, 0.9), color, width: 1.6 }] : [], from: 0.6, to: 0.5, spread: 0.5 },\n    ];\n  }, [size, data, variant, curve, dot, color, lo, hi]);\n\n  return (\n    <span\n      ref={ref}\n      role=\"img\"\n      aria-label={label ?? `Trend from ${data[0]} to ${data[data.length - 1]}, ${data.length} values`}\n      className={`relative inline-block align-middle ${className}`}\n    >\n      {size && pens ? <PenLayers size={size} pens={pens} trigger={trigger} duration={duration} /> : null}\n    </span>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/scrollfx/sparkline.tsx"
    }
  ],
  "type": "registry:ui"
}