Foundations

Annotations

Call out thresholds, forecasts, or special events. Annotations augment tooltips, legends, and the visual layer without interfering with series registration.

Example

The sample chart combines horizontal line annotations for temperature targets with labels that reflow to avoid overlapping the data.

Usage

<Chart.Annotation
  type="line"
  y={75}
  label="Supply target"
  color="var(--ambient-data-series-5)"
  strokeDasharray="4,4"
/>
<Chart.Annotation
  type="line"
  y={82}
  label="Return threshold"
/>
<Chart.Annotation
  type="line"
  x={changeTimestamp}
  label="Filter change detected"
  labelMarkOptions={{ frameAnchor: "bottom", dy: -10 }}
/>

Props

Chart.Annotation
PropTypeDefaultDescription
type`"line" | "x-band" | "y-band" | "point"`Select the annotation primitive. Horizontal `line` annotations use `y`, vertical use `x`.
xDomainInputX-position for vertical lines or points. Accepts Date or numeric values.
ynumberY-position for horizontal lines or points. Uses the same units as the axis domain.
labelstringOptional text label rendered near the annotation. Fine-tune placement through `labelMarkOptions`.
colorstringTheme annotation tokenStroke colour and tooltip accent for the annotation. Use theme variables where possible.
axisstring`"y"`Bind to a secondary axis so transformed values align correctly with dual-axis charts.
strokeWidthnumber1Line weight for the annotation stroke.
strokeDasharraystringPattern for dashed annotations (`"4,2"`). Helpful for forecast markers.
labelMarkOptions`Partial<Plot.TextOptions>`Advanced text mark configuration forwarded to Observable Plot. Control `textAnchor`, `lineAnchor`, `frameAnchor`, `dx`, `dy`, `rotate`, and more.

Recommendations

  • Use high-contrast colours so annotations remain legible.
  • Keep labels short; the tooltip already surfaces full annotation details.
  • Align annotation axes with the series they describe to avoid confusion when using secondary scales.