Area
area fills the region under a series. It groups and orders rows as line does, and takes the same handles, drags and sweeps. areaY fills to the y baseline, areaX to the x baseline. Give the value axis an endpoint pair (y1 + y2) and it fills between them instead, as an uncertainty band you edit by both edges.
API reference
area(options) · areaY(options) · areaX(options)
Import plot from elicitjs. One filled path per series, with an optional draggable handle per datum. areaY fills to the y baseline, areaX to the x baseline; bare area infers the value axis.
area({ channels, orientation, curve, connect, handles, handleSize, handleColor, edits, id }) → Mark
areaY(options) → Mark // value on y
areaX(options) → Mark // value on x| Option | Type · default | Description |
|---|---|---|
channels | objectdefault{} | Channel map — see Channels. |
image | string | | The shape's background image: a URL painted inside each shape in place of the fill. Takes fit, position and repeat as channel params, as in CSS. See Image. |
orientation | 'vertical' | defaultauto | Which axis the value runs along ( 'vertical' = y). Inferred from a band scale, an endpoint pair, or the lone bound channel; areaY / areaX pin it. |
channels.series | channeldefaultauto | The column grouping points into separate areas. Defaults to fill’s field, then stroke’s. |
channels.order | channel | The column each series is sorted by, when array order and the domain axis are both wrong. |
connect | 'domain' | default'domain' | How points join when no order channel is given: sorted by the domain axis, or as drawn. |
curve | stringdefault'linear' | Interpolation between handles (e.g. "catmullRom", "step"). |
handles | boolean | defaulttrue with an edit | true draws a grabbable circle per datum. 'hit' keeps the grab target but draws nothing. false is neither drawn nor grabbable, so a sweep or nearest pick has nothing to target. The default is true when the mark carries an edit and false otherwise. |
handleSize | numberdefault5 | Pixel radius of each handle. |
handleColor | stringdefaulttheme | Handle fill. Defaults to the area’s own colour (its stroke, else its fill); the ring is the theme’s handleStroke. |
gradient | { stops, | A linear-gradient fill over the area’s own box, in place of a flat fill. stops is a list of [offset, colour] with offsets 0–1; direction is 'vertical' (default, bottom to top) or 'horizontal' (left to right). |
edits, | As on every mark. Area authoring edits live under edit.line.*, which it shares with line. |
| Channel | Type | Description |
|---|---|---|
x / y | linear | | Domain and value axes (same as line). |
y1 / y2 · x1 / x2 | linear | An endpoint pair on the value axis: fill between the two fields instead of down to the baseline (a confidence band, a fan chart). They share the value axis’s scale, so they resolve exactly like y, and declaring a pair picks the value axis on its own. With one end given, the other is the baseline. Handles appear on each declared edge. Same span/baseline split bar and rect make, spelled the same way. |
fill / stroke | const | | Area fill (default fillOpacity 0.35) and outline. A field here also becomes the default series grouping. |
strokeDash | const | | Outline dash pattern: an SVG dash array ( '4 2'), or a field mapped onto a dash vocabulary. Takes legend: true. |
A mark emitting one filled path per series plus optional handle circles.
Filled series
Drag a handle to reshape the curve. Each handle takes the area's colour. By default, handles draw only when the area carries an edit; handles: true draws them without one.
Editable area
areaY with drag on y handles.
const chart = Elicit({width: 400, height: 260,margins: { top: 16, right: 16, bottom: 28, left: 34 },data: [{ t: 1, n: 20 }, { t: 2, n: 45 }, { t: 3, n: 35 },{ t: 4, n: 60 }, { t: 5, n: 50 },],schema: {t: { type: "quantitative", domain: [1, 5] },n: { type: "quantitative", domain: [0, 100] },},marks: [areaY({fill: "#50AEB7",channels: {x: { field: "t" },y: { field: "n", edit: move() },},}),],});mount(chart.dom());
Invisible handles
handles: 'hit' keeps the handles grabbable but invisible, as on line and arc. handles: false removes them entirely; a sweep or nearest pick then has nothing to target and logs a warning.
handles: 'hit'
Same area as above; the handles are invisible but still draggable.
// handles: 'hit' — invisible but grabbable (shared contract with line/arc).const chart = Elicit({width: 400, height: 260,margins: { top: 16, right: 16, bottom: 28, left: 34 },data: [{ t: 1, n: 20 }, { t: 2, n: 45 }, { t: 3, n: 35 },{ t: 4, n: 60 }, { t: 5, n: 50 },],schema: {t: { type: "quantitative", domain: [1, 5] },n: { type: "quantitative", domain: [0, 100] },},marks: [areaY({handles: 'hit',fill: "#50AEB7",channels: {x: { field: "t" },y: { field: "n", edit: move() },},}),],});mount(chart.dom());
Gradient fill
gradient: { stops, direction } fills the area with a linear gradient instead of a flat fill. Each stop is [offset, colour], with offset from 0 to 1 across the area's own box. direction: 'vertical' (the default) runs from bottom (0) to top (1); 'horizontal' runs left to right. bar and rect take the same option.
A gradient fill
gradient: { stops: [[0, pale], [1, blue]] } fades the area toward its baseline.
const chart = Elicit({width: 400, height: 260,margins: { top: 16, right: 16, bottom: 28, left: 34 },data: [{ t: 1, n: 20 }, { t: 2, n: 45 }, { t: 3, n: 35 },{ t: 4, n: 60 }, { t: 5, n: 50 },],schema: {t: { type: "quantitative", domain: [1, 5] },n: { type: "quantitative", domain: [0, 100] },},marks: [areaY({fillOpacity: 0.9,// Offset 0 is the bottom of the area's box, 1 the top.gradient: { stops: [[0, "#EDF7F8"], [1, "#50AEB7"]], direction: "vertical" },channels: {x: { field: "t" },y: { field: "n", edit: move() },},}),],});mount(chart.dom());
Uncertainty band
Give the value axis an endpoint pair and the area fills between them, as in a confidence interval or a fan chart. Both edges get handles, so you set the interval by dragging its ends. Add the ordering constraint to keep the band the right way up: drag the low edge above the high one and the high edge moves with it, since the edge you grabbed is the one you meant.
A row whose value is null, undefined or NaN breaks the area or band there, as on a line, and has no handle. To repaint one edge in a single drag, put edit.line.sweep() on y1 and y2; see Sweeping a band.
An editable confidence band
areaY with a y1/y2 pair; ordering keeps lo ≤ hi.
const chart = Elicit({width: 400, height: 260,margins: { top: 16, right: 16, bottom: 28, left: 34 },data: [{ year: 2025, lo: 20, hi: 45 }, { year: 2026, lo: 25, hi: 60 },{ year: 2027, lo: 22, hi: 72 }, { year: 2028, lo: 18, hi: 85 },],schema: {year: { type: "quantitative", domain: [2025, 2028] },lo: { type: "quantitative", domain: [0, 100] },hi: { type: "quantitative", domain: [0, 100] },},// A dataset invariant: it holds whichever edge you grab.constraints: [ ordering({ field: ["lo", "hi"] }) ],marks: [areaY({fill: "#50AEB7",channels: {x: { field: "year" },// An endpoint PAIR instead of a single value: fill BETWEEN the two// fields rather than down to the baseline. Declaring the pair is what// picks the value axis, and both edges get handles.y1: { field: "lo", edit: move({ channels: ["y1"] }) },y2: { field: "hi", edit: move({ channels: ["y2"] }) },},}),],});mount(chart.dom());