Skip to main content
A geom is what a chart draws for its data: a line, a bar, a point. Each geom is a layer in the spec; add several and they stack into one chart. Mappings and scales decide where things go; geoms decide what is drawn there.

The built-in geoms

Each is a function that returns a layer. Pass options to configure the layer, and geom-specific params for its geometry and behavior. Paint (colors, widths, opacities) lives in the stylesheet instead:

Params and paint, geom by geom

params set geometry and behavior; the style.* target beside them holds the geom’s paint. Every target also takes the shared alpha and saturation, plus its paint word: fill on a bar, area, point or tile, stroke on a line or rule. A dash pattern is a dashArray in the stylesheet ([] solid, [4, 2] dashed) and a lineType name ('solid', 'dashed', 'dotted') when mapped from data. Two things catch people out. A geom’s cornerRadius is a token ('none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full') or a number of pixels. And a defaults entry loses to a mapped aesthetic, while an overrides entry beats it. Styling has the full cascade.
A params key the geom does not declare is accepted and ignored.

Layers

Every geom.*() you pipe in adds a layer. Layers draw in order, so later ones sit on top. They share the spec-level mapping unless one overrides it. This is how combo charts are built:

Common layer options

Beyond params, every geom accepts these options:

Position modes

When several observations share the same x (because color or group splits the data), a layer’s position decides how they arrange: Each geom has its own default: geom.bar() is 'dodge', geom.area() is 'stack', and geom.point(), geom.line(), geom.rule() and geom.tile() are 'identity'. So a bar chart with a color mapping comes out grouped and an area chart comes out stacked, with no position of your own. geom.tile() accepts only 'identity'; any other value fails to compile.
Dodge works the same way for every geom: each group gets a share of the band. A bar fills its share; a point or line vertex stands at its center. Dodged layers line up, so dodge the points over a grouped bar chart and each point lands on its own bar:
A dodged line moves with its points, so the two stay together. Dodge needs a band, so it only moves anything on a band axis. On a continuous x axis a dodged layer stays at its values.

Next