{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "event-barcode",
  "type": "registry:component",
  "title": "Event barcode",
  "description": "Every event as a thin line, by service. Sample data: requests to chat API, embeddings and agents over 24 hours, OK, slow and error.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-barcode"
  ],
  "files": [
    {
      "path": "registry/chartory/components/event-barcode.tsx",
      "type": "registry:component",
      "target": "components/chartory/event-barcode.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Event barcode (Chartory chart 061): sizes xs | s | m | l, laid out again from the data at each\n// size; collection \"hearth\" (default) or \"signal\" (with @chartory/signal, Code and Complete). Data in the type's shape (default: the sample). Docs:\n// https://usechartory.com/docs/charts/event-barcode\nimport { ChartView, type ChartViewProps } from \"@/lib/chartory/charts/chart-view\"\nimport { registerChart } from \"@/lib/chartory/charts/defs\"\nimport { data as sample } from \"@/lib/chartory/charts/types/061-event-barcode/data\"\nimport { def } from \"@/lib/chartory/charts/types/061-event-barcode/layout\"\n\nregisterChart(def, sample)\n\nexport type EventBarcodeData = typeof sample\nexport type EventBarcodeProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: EventBarcodeData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: EventBarcodeData[]\n}\n\nexport function EventBarcode(props: EventBarcodeProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/061-event-barcode/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/061-event-barcode/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 061 Event barcode · sample data (Figma chart/061, request outcomes over the last 24 h on 3 services; events seeded).\nimport type { BarcodeData } from \"../../plots/barcode\";\n\nexport const data: BarcodeData = {\n  seed: 61,\n  weights: [0.05, 0.03, 0.02, 0.02, 0.03, 0.08, 0.2, 0.4, 0.62, 0.74, 0.8, 0.76, 0.66, 0.7, 0.74, 0.8, 0.88, 0.95, 1, 0.86, 0.6, 0.38, 0.2, 0.1],\n  xl: { 0: \"00:00\", 6: \"06:00\", 12: \"12:00\", 18: \"18:00\", 24: \"NOW\" },\n  rows: [\n    { label: \"Chat API\", n: 150, err: 0.02, slow: 0.06 },\n    { label: \"Embeddings\", n: 110, err: 0.005, slow: 0.02 },\n    { label: \"Agents\", n: 90, err: 0.06, slow: 0.12 },\n  ],\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/061-event-barcode/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/061-event-barcode/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 061 Event barcode (Figma chart/061, \"Request outcomes\"): C.barcode, sampled requests per service over 24 h.\nimport type { ChartDef, TooltipSpec } from \"../../core/shell\";\nimport { barcode } from \"../../plots/barcode\";\nimport { data } from \"./data\";\n\nconst pct = (v: number) => +(v * 100).toFixed(1) + \"%\";\n\nconst r4 = (v: number) => Math.round(v * 10000) / 10000;\n\n/** Outcome counts per lane, drawn exactly as the plot draws them (same seeded sequence, lane after lane). */\nconst outcomes = (o: typeof data): { ok: number; slow: number; err: number }[] => {\n  let s = o.seed ?? 7;\n  const rnd = () => { s = (s * 16807) % 2147483647; return s / 2147483647; };\n  const wm = Math.max(...o.weights);\n  return o.rows.map((row) => {\n    const c = { ok: 0, slow: 0, err: 0 };\n    let made = 0, guard = 0;\n    while (made < row.n && guard++ < row.n * 20) {\n      const t = rnd();\n      if (rnd() > o.weights[Math.min(23, Math.floor(t * 24))] / wm) continue;\n      const q = rnd();\n      if (q < row.err) c.err++; else if (q < row.err + row.slow) c.slow++; else c.ok++;\n      made++;\n    }\n    return c;\n  });\n};\n\n// tooltip: one service lane (group = lane): its sampled requests by outcome over the 24 h\nconst tip = (o: typeof data, g: number): TooltipSpec | null => {\n  const r = o.rows[g], c = outcomes(o)[g];\n  if (!r || !c) return null;\n  const n = c.ok + c.slow + c.err;\n  return {\n    kind: \"series\",\n    caps: r.label.toUpperCase() + \" · LAST 24 H\",\n    rows: [\n      { label: \"OK\", value: String(c.ok), swatch: \"text/action\" },\n      { label: \"Slow\", value: String(c.slow), swatch: \"status/warning\" },\n      { label: \"Error\", value: String(c.err), swatch: \"status/danger\" },\n    ],\n    total: { label: \"Requests\", value: String(n) },\n  };\n};\n\nexport const def: ChartDef = {\n  no: 61,\n  slug: \"event-barcode\",\n  legend: [[\"text/action\", \"OK\"], [\"status/warning\", \"Slow\"], [\"status/danger\", \"Error\"]],\n  plot: (K, p, w, d) => barcode(K, p, w, (d as typeof data | undefined) ?? data),\n  tip: (d, g) => tip(d as typeof data, g),\n  // the next 24 h: a new sample of the same number of requests per service, error and slow rates move up to ±25 %\n  update: (d, step) => {\n    const o = d as typeof data;\n    return { ...o, seed: (o.seed ?? 7) + step * 97, rows: o.rows.map((r, k) => ({ ...r, err: r4(r.err * (1 + 0.25 * Math.sin(k * 1.9 + step * 2.2))), slow: r4(r.slow * (1 + 0.2 * Math.sin(k * 1.1 + step * 1.6))) })) };\n  },\n  describe: {\n    title: \"Request outcomes\",\n    summary: `${data.rows.reduce((a, r) => a + r.n, 0)} sampled requests over the last 24 hours on ${data.rows.length} services; Agents has the highest error rate at ${pct(data.rows[2].err)}.`,\n    table: { head: [\"Service\", \"Sampled requests\", \"Error rate\", \"Slow rate\"], rows: data.rows.map((r) => [r.label, r.n, pct(r.err), pct(r.slow)]) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "schedule-and-status"
  ],
  "meta": {
    "access": "free",
    "no": 61,
    "family": "Schedule and status"
  }
}
