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
| Prop | Type | Default | Description |
|---|---|---|---|
| type | `"line" | "x-band" | "y-band" | "point"` | — | Select the annotation primitive. Horizontal `line` annotations use `y`, vertical use `x`. |
| x | DomainInput | — | X-position for vertical lines or points. Accepts Date or numeric values. |
| y | number | — | Y-position for horizontal lines or points. Uses the same units as the axis domain. |
| label | string | — | Optional text label rendered near the annotation. Fine-tune placement through `labelMarkOptions`. |
| color | string | Theme annotation token | Stroke colour and tooltip accent for the annotation. Use theme variables where possible. |
| axis | string | `"y"` | Bind to a secondary axis so transformed values align correctly with dual-axis charts. |
| strokeWidth | number | 1 | Line weight for the annotation stroke. |
| strokeDasharray | string | — | Pattern 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.