Position scales must be declared
Position scales are never created automatically. If you mapx or y, you must add scale.x() / scale.y(). Miss one and that axis has no scale, producing NaN positions and a blank chart.
color, size, …) are more forgiving — a mapped color without an explicit scale falls back to the default palette — but declaring them keeps a chart predictable.
Inference vs explicit types
Position scales are callable to infer their type from the mapped column’s value format:- text → discrete (band) scale
- number / percentage / currency → continuous scale
- date → temporal scale
Scales by aesthetic
Color scales
Identity scales
An identity scale passes data values straight through as visual values —{ size: 10 } becomes 10px, no transformation. Useful when your data already holds pixel sizes or CSS colors.
Continuous scale options
The continuous methods (and.log() / .sqrt(), which are continuous with a transform) accept:
Force the lower bound of the domain.
domainMin: 0 makes an axis start at
zero.Force the upper bound of the domain.
Extend the domain to round values —
[3, 97] becomes [0, 100].Include zero in the domain.
Reverse the direction of the scale.
A mathematical transform applied to the scale.
scale.y.log() is shorthand
for transform: 'log'.Discrete scale options
The categories, in the order they should appear. Omit to derive them from the
data.
Explicit output values — colors, sizes, or dash patterns — aligned to
domain.Next
- Coordinate systems — the plane scales place values into
- Chart types — scales at work in each recipe

