geom.rule(), layered into the spec with its own value and style.
A horizontal goal line
Bind the rule to a constanty with aes: { y: { value } }. The { value } form is a constant mapping — it pins the aesthetic to a literal instead of a column:
Styling the line
Style the rule through itsparams:
Optional inline text drawn alongside the line. Omit to draw a bare line.
Anchors the label at the start or end of the line.
Stroke color. Falls back to the theme’s reference-line token when unset.
Line thickness in pixels.
Stroke style.
Vertical lines
Mark a constant along the x-axis withaes: { x: { value } } instead:
A vertical rule requires a numeric x-axis — it marks a constant x-value,
which only has meaning when x is continuous. Categorical and date x-axes
support horizontal rules only.
Multiple rules
Rules compose like any other layer, and paint in spec order — a rule added aftergeom.bar() draws in front of the bars. Stack as many as you need:
Flipped and secondary axes
A rule tracks the data space, not the screen. Undercoord.flip() a { y: { value } } rule still marks a constant y — the renderer paints it as a vertical line because the y-axis now runs horizontally. To pin a rule to a secondary axis, add yScaleType: 'secondary':
Related
- Mappings & aesthetics — the
{ value }constant form - Scales — how the rule value extends the auto-domain
- Coordinate systems — rules under
coord.flip()

