{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ascii-chart",
  "title": "ASCII Chart",
  "description": "Line, bar and sparkline charts drawn in glyphs, with a hidden data table for screen readers.",
  "dependencies": [],
  "registryDependencies": [
    "https://dotgrain.space/r/engine.json"
  ],
  "files": [
    {
      "path": "registry/ui/ascii-chart.tsx",
      "content": "\"use client\";\n\nimport type { CSSProperties, Ref } from \"react\";\nimport { GLYPH_ASPECT } from \"@/lib/dotgrain/glyphs\";\nimport { useDitherTokens } from \"@/lib/dotgrain/provider\";\nimport { Quantize } from \"@/lib/dotgrain/quantize\";\nimport type { DitherTokens } from \"@/lib/dotgrain/types\";\n\nexport type AsciiChartProps = Partial<Omit<DitherTokens, \"mode\" | \"pattern\" | \"speed\">> & {\n  /** The series, one number per point. */\n  data: number[];\n  /** Line or bars filling the box, or an inline one-row sparkline. */\n  type?: \"line\" | \"bar\" | \"sparkline\";\n  /** What the data is; captions the hidden table that screen readers get. */\n  label: string;\n  /** Row headers for the hidden table, e.g. dates; defaults to 1, 2, 3… */\n  labels?: string[];\n  className?: string;\n  style?: CSSProperties;\n  ref?: Ref<HTMLDivElement>;\n};\n\nconst hidden: CSSProperties = { position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\", whiteSpace: \"nowrap\" };\n\nexport function AsciiChart({ data, type = \"line\", label, labels, className, style, ref, ...tokens }: AsciiChartProps) {\n  const { cell } = useDitherTokens({ ...tokens, mode: \"ascii\" });\n  const spark = type === \"sparkline\";\n  // A sparkline is one glyph per point in a single row; the blocks ramp draws its partial heights.\n  const size: CSSProperties = spark ? { display: \"inline-block\", verticalAlign: \"middle\", width: data.length * cell * GLYPH_ASPECT, height: cell } : { height: 160 };\n  return (\n    <div ref={ref} className={className} style={{ position: \"relative\", ...size, ...style }}>\n      <Quantize\n        source={{ kind: \"plot\", series: data, type: type === \"line\" ? \"line\" : \"bar\" }}\n        {...tokens}\n        glyphs={tokens.glyphs ?? (spark ? \"blocks\" : undefined)}\n        mode=\"ascii\"\n        style={{ position: \"absolute\", inset: 0 }}\n      />\n      <table style={hidden}>\n        <caption>{label}</caption>\n        <tbody>\n          {data.map((v, i) => (\n            <tr key={i}>\n              <th scope=\"row\">{labels?.[i] ?? i + 1}</th>\n              <td>{v}</td>\n            </tr>\n          ))}\n        </tbody>\n      </table>\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "modes": [
      "ascii"
    ]
  },
  "categories": [
    "data"
  ],
  "type": "registry:ui"
}