{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-line-annotations",
  "title": "Annotated Line Chart",
  "description": "An error rate with an SLO line, a shaded incident window and a deploy marker.",
  "dependencies": [
    "@wick-charts/react@^0.9.2"
  ],
  "registryDependencies": [
    "card",
    "https://wick-charts.eeff.io/r/wick-chart.json"
  ],
  "files": [
    {
      "path": "blocks/chart-line-annotations.tsx",
      "content": "\"use client\"\n\nimport {\n  Crosshair,\n  LineSeries,\n  Marker,\n  ReferenceLine,\n  TimeAxis,\n  type TimePoint,\n  TimeRegion,\n  Tooltip,\n  YAxis,\n} from \"@wick-charts/react\"\n\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\"\nimport { WickChart } from \"@/components/ui/wick-chart\"\n\nconst MINUTE_MS = 60_000\nconst POINTS = 120\n\nconst formatPercent = (value: number) => `${value.toFixed(2)}%`\n\nconst axis = { y: { min: 0 } }\n// Headroom over the peaks, so the line stays below the region's label chip.\nconst padding = { top: 40 }\nconst lineOptions = { pulse: false }\n\n// Seeded, so every render shows the same picture.\nfunction seededRandom(seed: number): () => number {\n  let state = seed\n\n  return () => {\n    state = (state * 1_664_525 + 1_013_904_223) % 4_294_967_296\n\n    return state / 4_294_967_296\n  }\n}\n\n// Demo data: a calm error rate, a deploy, then an incident above the SLO. The baseline stays\n// flat and the deploy comes well before the spike, so the deploy callout hides no data.\nfunction makeErrors(): {\n  points: TimePoint[]\n  deployAt: number\n  incidentFrom: number\n  incidentTo: number\n} {\n  const random = seededRandom(11)\n  const start =\n    Math.floor(Date.now() / MINUTE_MS) * MINUTE_MS - POINTS * MINUTE_MS\n  const incidentFrom = start + 70 * MINUTE_MS\n  const incidentTo = start + 88 * MINUTE_MS\n  const points: TimePoint[] = []\n\n  for (let minute = 0; minute < POINTS; minute++) {\n    const time = start + minute * MINUTE_MS\n    const isIncident = time >= incidentFrom && time <= incidentTo\n    const value = isIncident ? 1.6 + random() * 1.2 : 0.42 + random() * 0.08\n    points.push({ time, value })\n  }\n\n  return {\n    points,\n    deployAt: incidentFrom - 24 * MINUTE_MS,\n    incidentFrom,\n    incidentTo,\n  }\n}\n\nconst errors = makeErrors()\n\nexport function ChartLineAnnotations() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Error rate</CardTitle>\n        <CardDescription>5xx share of requests, last 2 hours</CardDescription>\n      </CardHeader>\n      <CardContent>\n        <WickChart\n          className=\"aspect-auto h-[280px]\"\n          axis={axis}\n          padding={padding}\n        >\n          <TimeRegion\n            from={errors.incidentFrom}\n            to={errors.incidentTo}\n            label=\"incident\"\n          />\n          <LineSeries\n            id=\"errors\"\n            data={{ label: \"Errors\", data: errors.points }}\n            options={lineOptions}\n          />\n          <ReferenceLine value={1} label=\"SLO 1%\" />\n          <Marker\n            time={errors.deployAt}\n            seriesId=\"errors\"\n            shape=\"arrow-down\"\n            label=\"deploy v2.4\"\n          />\n          <YAxis format={formatPercent} />\n          <TimeAxis />\n          <Crosshair />\n          <Tooltip format={formatPercent} />\n        </WickChart>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "charts",
    "monitoring"
  ],
  "type": "registry:block"
}