Text
Data labels, value annotations, and positioned text.
Use text marks to label data points or annotate specific values. Text is almost always layered on top of another mark.
Value labels
Place the value above each bar. The text field names which datum field to display:
dy: -12 shifts labels 12 pixels above the data point. Without it, labels sit directly on the bar top.
Custom text field
Display any field from your data – not just x or y:
Alignment
textAnchor controls horizontal alignment relative to the data point:
| Value | Behavior |
|---|---|
"start" | Left-aligned at the point |
"center" | Centered on the point (default) |
"end" | Right-aligned at the point |
Properties
| Field | Type | Default | Description |
|---|---|---|---|
text | string | "text" | Field name to display as the label. |
dx | number | 0 | Horizontal offset in pixels. |
dy | number | 0 | Vertical offset in pixels. Negative moves up. |
fontSize | number | – | Override the theme font size. |
fontWeight | string | – | Override the font weight. |
textAnchor | "start" | "center" | "end" | "center" | Horizontal alignment. |