{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sparkline",
  "title": "Sparkline",
  "description": "A small trend line with the latest point marked.",
  "registryDependencies": [
    "https://spotcheckui.com/r/spotcheck-base.json"
  ],
  "files": [
    {
      "path": "registry/spotcheck/components/spotcheck/sparkline.tsx",
      "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst WIDTH = 160\nconst HEIGHT = 34\nconst PADDING = 3\nconst MARKER = 6\n\ntype SparklineProps = Omit<React.ComponentProps<\"svg\">, \"children\" | \"values\"> & {\n  values: number[]\n  /** Describes the trend for screen readers. Leave it out if the numbers are printed nearby. */\n  label?: string\n}\n\nexport function sparklinePoints(values: number[]) {\n  const max = Math.max(...values)\n  const min = Math.min(...values)\n  const range = max - min || 1\n  return values.map((value, index) => [\n    (index / Math.max(1, values.length - 1)) * WIDTH,\n    HEIGHT - PADDING - ((value - min) / range) * (HEIGHT - PADDING * 2),\n  ] as const)\n}\n\nexport function Sparkline({ values, label, className, ...props }: SparklineProps) {\n  const points = sparklinePoints(values)\n  const last = points.at(-1)\n  const path = points.map(([x, y], index) => `${index ? \"L\" : \"M\"}${x.toFixed(1)} ${y.toFixed(1)}`).join(\" \")\n\n  return (\n    <svg\n      viewBox={`0 0 ${WIDTH} ${HEIGHT}`}\n      preserveAspectRatio=\"none\"\n      role={label ? \"img\" : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn(\"block h-[34px] w-full\", className)}\n      {...props}\n    >\n      <path d={path} fill=\"none\" stroke=\"var(--ink)\" strokeWidth=\"1.6\" vectorEffect=\"non-scaling-stroke\" />\n      {last && (\n        <rect x={last[0] - MARKER / 2} y={last[1] - MARKER / 2} width={MARKER} height={MARKER} fill=\"var(--accent-ink)\" />\n      )}\n    </svg>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "core"
  ],
  "type": "registry:component"
}