Legends
encoding + scaleGuide meaning
→
symbol recipeCategorical, gradient, or composite
→
rect · line · textConcrete guide graphics
At a glance
| Action | Shortest call | Inference/defaults | Result |
|---|---|---|---|
createLegend |
createLegend() |
Current/unique compatible mark; right position | Categorical, size, stroke-width, gradient, interval, or opacity guide |
editLegend |
editLegend({ position: "left" }) |
Unique existing legend; omitted properties retained | Rematerialized layout and appearance |
| Focused edits | editLegendLabels({ fontSize: 11 }) |
Same target inference as editLegend |
One legend component rematerialized |
removeLegend |
removeLegend({ target: "points" }) |
Existing legend owner | All owned legend blocks removed |
Legends are inferred from final mark encodings and materialized as concrete graphics. Start with the family that matches the encoded channel and use the editing page when changing an existing guide.
Supported legend families
| Legend family | Supported marks | Channels | | — | — | — | | Categorical | point, line, area, bar, rect, arc | color, shape, strokeDash, or compatible composites | | Continuous gradient | point, aggregate bar, rect | sequential color | | Discretized interval | point | quantize, quantile, or threshold color | | Sampled | point, line, rule | field opacity, size, or strokeWidth |
Focused legend families
Errors and limitations
Continuous color legends support point, aggregate-bar, and rect marks. Field
opacity and discretized continuous legends remain point-only. Interactive legends are unsupported.
Combined point-series and quantitative-size legends require a right or left
side position so both blocks remain in one vertical stack. A left block must
fit outside any left y-axis guides; use sufficient margin and offset.
Standalone stroke-width legends currently use the right side and accept
count when created. Edit their quantitative mapping through editScale;
editLegend support for that sampled block is not yet part of the public
contract.
Right-side layout requires sufficient right margin; bottom layout requires
sufficient bottom margin; top layout requires enough top margin for its title,
item grid, offset, and optional border. The library reports a layout error
instead of resizing the Canvas or dropping symbol layers.