Interaction effects
An effect is how a mark looks while something happens to its row: the pointer is over it, it is selected, a drag holds it. Set effects in effects: { ... } on the Elicit spec. They paint over the mark and never change the data, so a data-driven fill comes back when the state ends. To draw the rules a gesture obeys, such as a clamp's bounds, see Guides.
API reference
effects (on Elicit)
The interaction-state feedback layer, passed as effects on Elicit. Keyed by state; partial sub-objects merge over the defaults, so you override just the part you care about. Rules (constraint bounds, a pick’s reach, a handle’s track) are not effects — they live on the edit’s guide.
effects: { hovered, selected, target, grabbed, motion }| Option | Type · default | Description |
|---|---|---|
hovered | false | defaultoutline | The pointer is over this mark, or a proximity pick resolved it. Both routes draw the same thing. false disables it. |
selected | false | defaultoutline | The mark is in the chart's selection (edit.select / chart.select). Outranks hovered. |
target | false | defaultoutline #2563eb, | The container a dragged node would join if released now (see Hierarchy). |
grabbed | false | defaultbrightness(0.82) | A drag on this mark is in flight. A string is shorthand for { filter }. |
motion | booleandefaulton with a mute, | Fade each change of state in and out over the spec’s motion.duration. true fades every state, false none. Off when the spec sets motion: false or the reader asks for reduced motion. |
<state>.filter | string | A CSS filter on the mark's own element — the one effect that survives a mid-drag re-render untouched. |
<state>.opacity · fill · stroke · strokeWidth · cursor | any | Element effects, applied as CSS properties so they override the mark's paint while set and are removed cleanly on exit. |
<state>.others | false | default— (a linked hover: { opacity: 0.3 }) | The mute: a restyle for every mark in no state, while this state holds on at least one row. false turns it off. |
<state>.neighbours | booleandefaultfalse | Network and hierarchy datasets only. The highlight also covers the rows linked to the row in this state: a node's links and the nodes at their other ends, a link's two nodes, and everything nested inside any hierarchy node it lights. |
hovered.link | true | defaulttrue with two or more charts on the dataset | Whether this chart’s hover is the dataset’s. true sends it and shows the other charts’ hover. 'receive' shows theirs and sends none. false keeps hover in this chart. |
<state>.outline | false | default{ color: 'auto', | An outline overlay traced on the mark’s edge, above every other layer. Handles every node type — circle, rect, line and path. Text is outlined only when the spec sets outline, as a box around the label. color: 'auto' reads the mark’s fill (or its stroke, when the fill is missing or near-white) and darkens it by darken (0.6 hovered, 1.5 selected; negative lightens). 'fill' / 'stroke' pick that paint; a CSS colour fixes it; a function (color, node) => string rewrites it. fallback paints when nothing can be read. padding moves the trace out from the edge. |
Effects draw either as CSS properties on the element or as overlay nodes — never as the fill/stroke attributes a mark’s channels write — so they can’t clobber data-driven style.
How highlighting works
Every effect answers four questions. Each has its own option.
| Question | Option | Default |
| --- | --- | --- |
| Which rows are in a state? | the state: hovered, selected, target, grabbed | set by the pointer and the selection |
| How does a row in the state look? | the state's own options: restyle props and outline | an outline |
| How do the other rows look meanwhile? | others, the mute | unchanged |
| Which rows count as in the state? | neighbours, and hovered.link across charts | the row itself, in this chart |
A state's own options are its highlight. others is its mute: it restyles every row in no state, for as long as the state holds a row. A row in any state is never muted.
By default, hover lights only the editable mark under the pointer. Set others or neighbours on hovered, or link hover across charts, and hover lights the whole row: every mark that draws it, view-only marks too.
motion sits beside the states and fades every change in and out. It is on by default wherever a highlight changes other rows: a mute, neighbours, or a linked hover. See Fade in and out.
effects: {hovered: { neighbours: true, others: { opacity: 0.2 } }, // light the row and what it links to, fade the restselected: { outline: { width: 4 } },motion: true, // fade every state, plain hover too}
The states
effects is keyed by state, and every state takes the same options.
hovered applies when the pointer is over the mark, or when a proximity pick resolves to it. Pointing at a mark and a pick: "nearest" edit choosing it draw the same thing.
selected applies when the mark is in the interface's selection.
target outlines the container a dragged node would join if you released it now. See Hierarchy. Its default outline is #2563eb, padded 3px out from the edge.
grabbed applies while you drag the mark. Pass a string as shorthand for { filter }.
Set a state to false to switch it off.
Hover on an editable mark
hovered applies to every editable mark by default, with or without a pick.
Point at a draggable bar and it responds before you press.
A plain draggable bar
A single move() on y. Nothing in the spec asks for hover feedback.
const chart = Elicit({width: 380, height: 240,margins: { top: 14, right: 14, bottom: 28, left: 34 },data: [{ cat: "A", n: 62 }, { cat: "B", n: 38 },{ cat: "C", n: 81 }, { cat: "D", n: 24 },],schema: {cat: { type: "categorical", domain: ["A", "B", "C", "D"] },n: { type: "quantitative", domain: [0, 100] },},marks: [bar({channels: {x: { field: "cat" },// A plain direct-pick edit: you point straight at the bar. `hovered`// applies to it like any other editable mark.y: { field: "n", edit: move() },},}),],});mount(chart.dom());
The highlight: restyle and outline
A state's highlight paints in one of two ways, and can use both at once.
Element props restyle the mark itself: filter, opacity, fill, stroke,
strokeWidth, cursor. They override the mark's own paint while the state holds,
and the mark's paint returns when it ends. Every prop paints in both
renderers. On canvas, filter needs a browser whose 2D context has
filter; in any other it logs a warning.
outline draws an overlay on the mark's edge, above every other layer. It takes
color, darken, fallback, width, padding, dash and opacity, and traces
whatever shape the mark is: a ring on a circle or ellipse, the box on a rect (with its
corner radius), the segment on a tick, the path itself on an arc slice, line or
polygon. padding moves the trace out from the edge, and is 0 by default.
A text label gets no outline by default. The cursor change is its feedback. Set
outline for a state in effects and labels get a box around the text in that state.
The outline's colour comes from the mark. With the default color: "auto", it is
the mark's fill, or its stroke when the fill is missing or near-white, darkened by
darken (0.6 for hovered, 1.5 for selected; a negative value lightens). A teal bar
lights up in deep teal and a coral dot in deep coral. "fill" or "stroke" reads
that paint only. A CSS colour fixes the outline to that colour. A function
(color, node) => string receives the derived colour and returns the one to paint.
fallback is used when the mark's paint can't be read, such as a gradient fill.
Element props follow the mark wherever it goes. An outline copies the mark's
rotation: rotate a mark with an angle channel and its outline
turns with it. Proximity picking measures the same rotated shape, so the mark that
lights up is the mark a drag grabs.
Element props, and outline
Left restyles the dot; right leaves it alone and rings it. Both keep the fill the data gives it.
// Two ways to paint a state, both available on every state.//// element props filter / opacity / fill / stroke / strokeWidth / cursor —// restyle the mark itself, without writing its own paint.// outline an overlay traced around the mark, above every layer.//// Left uses element props, right an outline. The dots keep the fill their `group`// field gives them in both.const rows = [{ x: 22, y: 34, group: "a" },{ x: 50, y: 66, group: "b" },{ x: 78, y: 40, group: "a" },];const schema = {x: { type: "quantitative", domain: [0, 100] },y: { type: "quantitative", domain: [0, 100] },group: { type: "categorical", domain: ["a", "b"] },};const dots = () => point({size: 11,channels: {x: { field: "x", edit: move() },y: { field: "y", edit: move() },fill: { field: "group" },},});// Element props: the dot brightens and thickens. No overlay.mount(Elicit({width: 300, height: 220,margins: { top: 14, right: 14, bottom: 26, left: 30 },data: rows, schema,effects: {hovered: { filter: "brightness(1.25)", strokeWidth: 4 },grabbed: { filter: "brightness(0.8)" },selected: false,},marks: [ dots() ],}).dom());// Outline: the dot is untouched, and a ring is drawn around it.mount(Elicit({width: 300, height: 220,margins: { top: 14, right: 14, bottom: 26, left: 30 },data: rows, schema,effects: {hovered: { outline: { color: "#20555A", width: 2, padding: 7, dash: "3 3", opacity: 0.9 } },selected: false,},marks: [ dots() ],}).dom());
Hovered and selected together
selected outranks hovered: a selected mark draws as selected while you hover it.
Give the two different weights. hovered shows which mark a gesture would take, and
selected shows which one you picked.
The interface holds the selection, separate from the data: edit.select writes no
selected field. See Editing a selected item.
A light hover, a firm selection
Alt-click selects, so a plain click still drags. A shallow shade on hover, a deep thick one on selection.
const chart = Elicit({width: 380, height: 250,margins: { top: 14, right: 14, bottom: 28, left: 34 },data: [{ cat: "A", n: 62 }, { cat: "B", n: 38 },{ cat: "C", n: 81 }, { cat: "D", n: 24 },],schema: {cat: { type: "categorical", domain: ["A", "B", "C", "D"] },n: { type: "quantitative", domain: [0, 100] },},// Different weights: `hovered` says which bar a gesture would take, `selected`// says which one you picked. `selected` outranks `hovered`. Both keep the default// `color: "auto"` (a shade of the bar's own colour); `darken` sets how deep.effects: {hovered: { outline: { darken: 0.3, width: 2 } },selected: { outline: { darken: 2, width: 4 } },grabbed: { filter: "brightness(0.85)" },},marks: [bar({channels: { x: { field: "cat" }, y: { field: "n", edit: move() } },// Selection is pipeline state, not a data column: nothing here writes a// `selected` field. Alt-click selects, so a plain click still drags.edits: [ select({ when: when.alt }) ],}),],});mount(chart.dom());
Highlight and mute
A state's own options are its highlight: how a mark in that state looks. others is its mute. It restyles every mark that is in no state, for as long as the state holds on at least one row. It takes the element props opacity, filter, fill, stroke and strokeWidth.
Every state takes others. On selected it gives a highlight that stays until you clear the selection.
Setting others on hovered makes hover apply to the row: every mark that draws the row lights up, on view-only marks too.
Select one, fade the rest
selected keeps its default outline. others fades the unselected bars.
const chart = Elicit({width: 380, height: 250,margins: { top: 14, right: 14, bottom: 28, left: 34 },data: [{ cat: "A", n: 62 }, { cat: "B", n: 38 },{ cat: "C", n: 81 }, { cat: "D", n: 24 },],schema: {cat: { type: "categorical", domain: ["A", "B", "C", "D"] },n: { type: "quantitative", domain: [0, 100] },},// `others` styles the bars that are in no state while one bar is selected.effects: {selected: { others: { opacity: 0.25 } },},marks: [bar({channels: { x: { field: "cat" }, y: { field: "n" } },edits: [ select({ toggle: true }) ],}),],});mount(chart.dom());
Neighbours in a network
neighbours: true extends a state's highlight to the rows linked to it. Hover a node and its links light up, with the nodes at their other ends. Hover a link and its two nodes light up. In a hierarchy, every node it lights brings everything nested inside it, so a container lit across a link lights its contents too.
neighbours applies to network and hierarchy datasets, where a ref column links one row to another. On a dataset with a single table it does nothing and logs a warning.
What a factor touches
neighbours lights the hovered factor's links and the factors they connect it to. others fades the rest.
// A network: factors (nodes) and what causes what (links).const chart = Elicit({width: 440, height: 260,margins: { top: 24, right: 44, bottom: 24, left: 44 },axes: false,schema: {structure: "network",tables: {nodes: {id: { type: "categorical", key: true },x: { type: "quantitative", domain: [0, 100] },y: { type: "quantitative", domain: [0, 100] },},links: {role: "links",directed: true,fields: { source: { type: "ref" }, target: { type: "ref" } },},},},data: {nodes: [{ id: "Interest rates", x: 16, y: 80 },],links: [{ source: "Interest rates", target: "House prices" },],},// Hover a factor: its links light up with it, and everything else fades.effects: {hovered: { neighbours: true, others: { opacity: 0.2 } },},marks: [link({ inset: 3, stroke: "#94A5B3", strokeWidth: 1.5 }),node({fill: "#50AEB7", size: 9,channels: { x: { field: "x" }, y: { field: "y" }, text: { field: "id" } },}),],});mount(chart.dom());
Hover across charts
hovered takes one more option, link. With link: true the chart's hover is the dataset's: the hovered row lights up in every chart on that dataset, and the other rows fade. It is on by default when two or more charts share a dataset. See Linked hover.
Fade in and out
effects.motion fades each change of state in and out instead of switching it at once. The highlight, the outline and the mute all ease, and a row leaving a state fades out.
It is on by default wherever a highlight changes other rows too: a state with others or neighbours, or a hover linked across charts. A plain hover outline switches at once. motion: true fades every state, and motion: false switches every state at once.
The fade takes the spec's motion.duration, 220 ms by default. motion: false on the spec turns it off with the rest of the chart's motion, as does reduced motion in the reader's system. Only the drawing fades; the data and the selection change at once.
Set effects: { motion: false } on a chart to switch its states at once.
To fade the UI layer too, pass { motion: true } to ui.attach.
A linked hover that fades
Two charts on one dataset. Hover a district in either: it lights in both, and the other rows fade to 0.2.
// Six districts: what people pay, and what they earn.const ds = Elicit.dataset({schema: {district: { type: "categorical", domain: ["Ash", "Birch", "Cedar", "Dale", "Elm", "Fern"] },rent: { type: "quantitative", domain: [0, 3000] },income: { type: "quantitative", domain: [0, 100] },},data: [{ district: "Ash", rent: 2400, income: 82 },],});// Two charts on one dataset link their hover. Both mute the other rows,// so both fade in and out by default.const bars = ds.chart({width: 440, height: 200,margins: { top: 10, right: 16, bottom: 30, left: 44 },axes: { y: { title: "Rent" } },effects: { hovered: { others: { opacity: 0.2 } } },marks: [bar({fill: "#50AEB7",channels: { x: { field: "district" }, y: { field: "rent", edit: move() } },}),],});const scatter = ds.chart({width: 440, height: 220,margins: { top: 10, right: 16, bottom: 36, left: 44 },axes: { x: { title: "Income" }, y: { title: "Rent" } },effects: { hovered: { others: { opacity: 0.2 } } },marks: [point({fill: "#F4A259", size: 7,channels: { x: { field: "income" }, y: { field: "rent" } },}),],});mount(bars.dom());mount(scatter.dom());
Switching a state off
false disables a state. Turn one off where the mark reads clearly on its own, such
as a dense grid where an outline per cell adds noise.
Feedback only on drag
hovered: false and selected: false; only the drag reads back.
// `false` disables a state. Here hover and selection are off, so only the drag// reads back.const chart = Elicit({width: 380, height: 240,margins: { top: 14, right: 14, bottom: 28, left: 34 },data: [{ cat: "A", n: 62 }, { cat: "B", n: 38 },{ cat: "C", n: 81 }, { cat: "D", n: 24 },],schema: {cat: { type: "categorical", domain: ["A", "B", "C", "D"] },n: { type: "quantitative", domain: [0, 100] },},effects: {hovered: false,selected: false,grabbed: { filter: "brightness(0.78) saturate(1.4)" },},marks: [bar({ channels: { x: { field: "cat" }, y: { field: "n", edit: move() } } }),],});mount(chart.dom());
Hover and proximity, one signal
A pick: "nearest" drag draws two things. The ring is the pick's catchment, a
guide on the edit. The outline on the resolved dot is the hovered
effect — the same one you get by pointing straight at a mark.
Proximity select
Move near a dot to select it; drag from empty space to grab the nearest.
const chart = Elicit({width: 340, height: 240,margins: { top: 14, right: 14, bottom: 26, left: 30 },data: [{ x: 25, y: 35 }, { x: 55, y: 68 }, { x: 78, y: 30 }],schema: {x: { type: "quantitative", domain: [0, 100] },y: { type: "quantitative", domain: [0, 100] },},marks: [point({fill: "#50AEB7",size: 10,channels: {x: { field: "x" },y: { field: "y" },},edits: [ move({ channels: ["x", "y"], pick: "nearest", threshold: 45, guide: true }) ],}),],});mount(chart.dom());
Customized effects
The same edit, restyled. The states go in effects. The ring goes in the edit's
guide: { catchment }, because it describes the pick, not the mark's state.
The dots keep the stroke you set throughout.
Restyled feedback
A fixed-colour ring padded out from the dot, a thicker selection, a softer grab — paint channels untouched.
const chart = Elicit({width: 340, height: 240,margins: { top: 14, right: 14, bottom: 26, left: 30 },// EFFECTS are interaction STATE. Each state takes the same vocabulary:// element props (filter / opacity / fill / stroke / strokeWidth / cursor) that// ride as CSS over the mark's own paint, plus an `outline` overlay.effects: {hovered: { outline: { color: "#50AEB7", width: 2, padding: 8, opacity: 0.7 } },selected: { outline: { color: "#50AEB7", width: 4, padding: 8, opacity: 1 } },grabbed: { filter: "brightness(1.08)" },},data: [{ x: 25, y: 35 }, { x: 55, y: 68 }, { x: 78, y: 30 }],schema: {x: { type: "quantitative", domain: [0, 100] },y: { type: "quantitative", domain: [0, 100] },},marks: [point({fill: "#50AEB7",size: 10,channels: {x: { field: "x" },y: { field: "y" },},// The snap ring is a GUIDE — it shows the pick's reach, a rule about what a// gesture will grab — so it is styled on the edit, not in `effects`.edits: [ move({channels: ["x", "y"], pick: "nearest", threshold: 45,guide: { catchment: { color: "#50AEB7", dash: "1 3", width: 1.5, opacity: 0.5 } },}) ],}),],});mount(chart.dom());