Skip to content
Sign in
DataChart annotationMenu

Chart annotationPro

Anomaly, event and note callouts pinned to points, with labels placed so none overlap each other or the line. A ready line chart, or a layer over any chart.

ProOctober checkout errors with a deploy anomaly, a rollback, an issuer rule change and retry tuning, labels placed without overlap.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/chart-annotation

Usage

tsx
import { AnnotatedChart } from "@/components/ui/chatcn/pro/chart-annotation"

<AnnotatedChart
  data={daily}
  xKey="day"
  yKey="errors"
  annotations={[{ id: "deploy", x: "12 Oct", kind: "anomaly", title: "502s after deploy", detail }]}
/>

Each label tries above, below and beside its point and only moves further out, with a leader line, when it has to; higher priority callouts (anomalies, then events) keep the best slots. For another chart, render ChartAnnotationLayer over it with pixel anchors and the points as obstacles; placeLabels in chatcn-pro-data-a exposes the placement on its own.

Examples

States

ProSeven crowded callouts, narrow, loading, no data and error.

Props

PropTypeNotes
data, xKey, yKeyrows, string, stringThe line
annotations{ id, x, kind?, title, detail?, priority? }[]Kinds: anomaly, event, note
activeId, defaultActiveId, onActiveChangestring | nullThe selected callout
valueFormat, unit, height, title, descriptionChart options
loading, error, onRetryChart states

Keyboard

KeyAction
TabMoves to the callouts as one stop
Left and RightPrevious or next callout in time
Enter or SpaceSelects or clears the callout
EscapeClears the selection

Accessibility

  • Callouts are toggle buttons named by kind and title; the detail below is a polite live region.
  • Kinds differ by icon and shape (ring, rule, dot), not only by amber, blue and gray.
  • The chart image is labelled with every callout and its date.

Motion

Selecting a callout dims the rest over 150 ms. Placement is computed, not animated, so labels never drift.