Elicit.js

Handles & affordances

Handles are grab targets on continuous shapes: curves, envelopes, partition seams and interval spans. They can be visible grips, invisible hit targets (handles: 'hit') or boundary seams. Every mark sizes, colours and hit-tests them the same way.

API reference

handles

The universal handle contract for continuous geometry — line, area, curve, arc, trend, needle, and a span. Every mark that draws a grip spells these the same way.

Options
OptionType · defaultDescription
handles
boolean | "hit"defaulttrue with an edit
Unset, a handle draws where an edit reaches the row. true always draws it, as ink on a mark with no edit. "hit" keeps the enlarged grab target without drawing a circle. false is neither drawn nor grabbable, so a sweep or nearest pick on the mark has nothing to target (the chart warns).
handleSize
numberdefault5
Radius in px of the grip and its pointer hitbox.
handleColor
stringdefaultseries colour · theme.handle
Grip fill. On line and area a grip is filled with its row's resolved stroke, so each series' grips match its line; trend uses its own ink, and other marks use theme.handle. The ring is theme.handleStroke. Setting handleColor overrides both fills.
Returns / emits

A grip is drawn only where an edit can use it. A mark with no edit on the channel draws none, whatever handles says.

moveSpan(options)

Translate a two-endpoint span — both endpoints move together, so its width is preserved.

moveSpan({ channels, when, stage }) → Edit
Options
OptionType · defaultDescription
channels
[string, string]defaultinjected
The span pair to govern, e.g. ["x1", "x2"] or ["y1", "y2"].

brushSpan(options)

The Gantt-bar interaction. Grabbing near one endpoint resizes that edge alone; grabbing the body translates both. The zone is resolved once, at the start of the drag.

brushSpan({ channels, edgeInset, guide, when }) → Edit
Options
OptionType · defaultDescription
channels
[string, string]defaultinjected
The span pair to govern, e.g. ["x1", "x2"] or ["y1", "y2"].
edgeInset
numberdefault8
Catchment width in px at each end: inside it the gesture resizes that edge, outside it moves the whole span.
pick
default'brush'
Fixed. brushSpan reads a zone only the brush driver sets, so it cannot be repointed at another pick.
Returns / emits

An Edit. Dragging one edge past the other is allowed mid-gesture; the pair is put back in order once, when you let go.

brushRect(options)

The 2-D counterpart: edges, corners and body of a rect, each live or not as you choose.

brushRect({ resize, move, edgeInset, when }) → Edit
Options
OptionType · defaultDescription
resize
'both' | 'x' | 'y' | 'none'default'both'
Which axes' edges and corners are live. 'none' leaves a pure 2-D move.
move
booleandefaulttrue
Whether a body drag translates the whole rect. false leaves a resize-only brush.
edgeInset
numberdefault8
Catchment width in px along each edge.
channels
string[]default['x1','x2','y1','y2']
The two endpoint pairs it governs.
Returns / emits

An Edit. A disabled zone degrades to the body, so resize: 'x' behaves like a per-axis brushSpan.

edit.stack.edge(options)

Drag an interior boundary to move value between the two segments it separates. The group total is preserved by construction.

edit.stack.edge(options?) → Edit
Options
OptionTypeDescription
—
EditOptions
The universal edit options. You grab the boundary handle itself, so it reads no threshold and draws no guide.

Visible grips vs. invisible hit targets

A line or area has no separate node per point to grab. Handles supply one.

Unset, a mark draws its handles where an edit reaches the row. handles: true draws a circular grip on each vertex, as ink when nothing edits the mark. handles: 'hit' draws no circles but keeps the enlarged hit targets along the path, so the chart stays uncluttered and still easy to drag. handles: false draws no handles, so an edit that targets them, such as a sweep or a nearest pick, has nothing to grab, and the chart warns.

On a line or area, a grip is filled with the row's resolved fill when the mark encodes one, otherwise its stroke. It is ringed with the theme's handleStroke. On a multi-series chart, each line's grips match it. handleColor sets one fill for every grip.

Invisible hit targets (handles: 'hit')

handles: 'hit' leaves no visible dots, but lets you drag along the top edge.

const chart = Elicit({
width: 380, height: 220,
margins: { top: 16, right: 16, bottom: 28, left: 34 },
data: [
{ t: 1, n: 20 }, { t: 2, n: 55 }, { t: 3, n: 35 },
{ t: 4, n: 70 }, { t: 5, n: 45 },
],
schema: {
t: { type: "quantitative", domain: [1, 5] },
n: { type: "quantitative", domain: [0, 100] },
},
marks: [
areaY({
handles: "hit",
fill: "#50AEB7",
opacity: 0.7,
channels: {
x: { field: "t" },
y: { field: "n", edit: move() },
},
}),
],
});
mount(chart.dom());
Try: Drag along the top edge of the area to reshape the distribution.

Boundary seams (arcs & stacked bars)

On a partition, handles sit at the interior boundaries between adjacent slices. An n-slice pie or stacked bar has n − 1 boundary handles.

edit.stack.edge() lets you drag a boundary to move value between the two slices beside it. The total stays constant.

Drag slice boundaries

Each handle pair-shifts adjacent shares while preserving the 100% total.

const chart = Elicit({
width: 300, height: 260,
margins: { top: 20, right: 20, bottom: 20, left: 20 },
axes: false,
data: [
{ source: "Solar", share: 45 },
],
schema: {
source: { type: "categorical" },
share: { type: "quantitative", domain: [0, 100] },
},
marks: [
arc({
outerRadius: 95,
edits: [edit.stack.edge()],
channels: {
theta: { field: "share" },
fill: { field: "source" },
},
}),
],
});
mount(chart.dom());
Try: Drag any slice boundary to reallocate share between categories.

Span endpoints & body brushes

On a mark with a range (x1/x2 or y1/y2), handles sit at the span's endpoints.

brushSpan() gives one mark two drags. Grab near an end to resize that bound, or grab the body to move the whole span. Drag the lower end past the upper one and the fields swap on release, so the order holds without a jump.

Resize edges or drag span body

Grab within edgeInset pixels to resize an endpoint; grab the centre to slide the task.

const chart = Elicit({
width: 380, height: 220,
margins: { top: 14, right: 16, bottom: 26, left: 60 },
data: [
{ task: "Research", start: 2, end: 6 },
],
schema: {
task: { type: "categorical", domain: ["Research", "Design", "Build"] },
start: { type: "quantitative", domain: [0, 14] },
end: { type: "quantitative", domain: [0, 14] },
},
marks: [
barX({
fill: "#50AEB7",
channels: {
y: { field: "task" },
x1: { field: "start" },
x2: { field: "end" },
},
edits: [
brushSpan({
channels: ["x1", "x2"],
threshold: 30,
edgeInset: 12,
guide: true,
}),
],
}),
],
});
mount(chart.dom());
Try: Drag an end handle to resize · drag the bar body to move the whole range.