Probe & stages
pick: "probe" previews an edit before it commits. Moving the pointer draws an uncommitted ghost, and getData() reports only the last settled answer. Stages split a question into steps: first do X, then do Y. Give an edit a numeric stage and it is active only in that stage; an edit with no stage is always active. Move between stages with nextStage(), setStage(n) and getStage(), and listen with on("stage", cb). A staged probe edit advances to the next stage when it commits.
API reference
anyEdit({ pick: "probe", stage, advance })
Not a new edit — a pick you give an existing one. It runs that edit twice. On hover or drag the proposal is parked as a preview and drawn as an inert ghost; on click or dragend the same proposal is committed. The ghost is therefore exactly what a commit writes. Both gestures settle, so a knob can be dragged as well as clicked.
rotate({ pick: "probe", stage: 0 }) // line follows the pointer; click sets it
move({ pick: "probe", advance: false }) // a knob that tracks then settles
create({ pick: "probe", advance: false }) // a tentative dot, made real on click
toggle({ pick: "probe", channels: ["x","y"] }) // preview a cell being (un)picked| Option | Type · default | Description |
|---|---|---|
stage | numberdefaultnull | Active only in this stage. A click settling it advances the chart to the next stage, freezing the field. |
advance | booleandefaulttrue | Set false so a click commits without advancing — the edit stays live for repeated answers. |
Previews never reach onChange, getData or the belief store; leaving the plot discards the proposal. Constraints run on the preview too, so a rejected value never even previews.
edit({ stage }) · container.setStage / nextStage / getStage
Add stage to any edit factory. The engine filters edits by the current stage in dispatch, cursor, plane-on-top, and guides — one gate everywhere.
move({ stage: 1 }) // active only in stage 1
const chart = Elicit({ stage: 0, ... });
chart.getStage() → number
chart.setStage(n) // set, emit "stage", re-render
chart.nextStage() // setStage(current + 1), stopping at done: one past the last stage an edit declares
chart.on("stage", (n) => …) // subscribe; returns an unsubscribe fn| Option | Type · default | Description |
|---|---|---|
edit.stage | numberdefaultnull | The stage this edit is active in. Unset, it is active in every stage. |
spec.stage | numberdefault0 | Which stage the chart starts on. |
spec.stageLabels | string[]default[] | A caption per stage, read back with getStageLabel(). |
edit.advance | booleandefaulttrue | Whether a settled probe click moves the chart on. Set false to answer repeatedly within one stage. |
setStage and nextStage emit stage and re-render. The stage gates dispatch, the cursor, plane pick order, and guides, so an edit outside the current stage is inert everywhere at once.
Ghost proposals
pick: "probe" splits an edit into preview and commit. As the pointer moves, the marks draw an inert ghost of what a commit would produce.
The proposal applies to the dataset, so every mark reading those rows shows the ghost. getData() and onChange stay unchanged until you commit.
Probe a single value
move({ pick: 'probe' }) displays a ghost knob that settles on click or drag release.
const chart = Elicit({width: 380, height: 130,margins: { top: 20, right: 24, bottom: 34, left: 24 },axes: { x: {}, y: false },data: [{ v: 20 }],schema: {v: { type: "quantitative", domain: [0, 100] },},constraints: [ clamp({ min: 0, max: 100, field: "v" }) ],marks: [point({id: "belief",size: 9, fill: "#50AEB7",channels: { x: { field: "v",edit: move({ pick: "probe", advance: false }) },},}),],});mount(chart.dom());const out = document.createElement("div");out.style.cssText = "font:12px ui-monospace,monospace;color:#6F8294";const show = () => { out.textContent = "committed: " + chart.getData()[0].v.toFixed(0); };chart.on("change", show); show();mount(out);
Two ways to commit
A probe edit commits on either gesture:
- Move, then click: move the pointer without pressing to place the ghost, then click to settle it.
- Grab and drag: press on the mark, drag to the value, and release.
Stages: place, then size
Stage 0 drags the point along x (where). Stage 1 resizes it (how confident). Only one edit is live at a time.
A staged probe edit advances the stage when it commits. Set advance: false on it to advance by hand instead.
Two-stage point
Same mark, two staged edits, a Next button.
const chart = Elicit({width: 380, height: 240,margins: { top: 16, right: 16, bottom: 28, left: 16 },axes: { x: {}, y: false },stage: 0,data: [{ x: 5, mag: 12 }],onChange: (d) => console.log(d[0]),schema: {x: { type: "quantitative", domain: [0, 10] },mag: { type: "quantitative", domain: [0, 14] },},marks: [point({channels: {x: { field: "x", edit: move({ stage: 0 }) },size: { field: "mag", edit: resize({ stage: 1 }) },},}),],});mount(chart.dom());const label = document.createElement("div");const render = () => { label.textContent = "stage: " + chart.getStage(); };chart.on("stage", render); render();const btn = document.createElement("button");btn.textContent = "Next";btn.onclick = () => chart.nextStage();const controls = document.createElement("div");controls.style.cssText = "margin-top:8px;display:flex;gap:10px;align-items:center";controls.append(btn, label);mount(controls);
Probe across stages
A probe edit with a stage advances to the next stage when it commits, unless it sets advance: false.
Two steps: slope, then spread
Stage 0 sets the trend slope; stage 1 opens the confidence cone.
const chart = Elicit({width: 320, height: 320,margins: { top: 20, right: 20, bottom: 20, left: 20 },axes: false,data: [{ r: 0, spread: 0 }],schema: {x: { type: "quantitative", domain: [-1, 1] },y: { type: "quantitative", domain: [-1, 1] },r: { type: "quantitative", domain: [-1, 1] },spread: { type: "quantitative", domain: [0, 1] },},marks: [trendBand({render: "samples", samples: 60,channels: {intercept: { datum: 0 },slope: { field: "r" },slopeSpread: { field: "spread" },},}),trend({id: "belief",handles: false,stroke: "#EE7B5E", strokeWidth: 3,channels: {intercept: { datum: 0 },// Stage 0: no handle to grab, so the gesture takes the pointer's own x// and the line simply follows the cursor. A click sets it and advances.slope: { field: "r", edit: edit.trend.slope({ pick: "probe", stage: 0 }) },// Stage 1: how far the line through the pointer tilts away from the// committed one is the envelope half-width.slopeSpread: { field: "spread", edit: edit.trend.slopeSpread({ pick: "probe", stage: 1 }) },},}),],});mount(chart.dom());const out = document.createElement("div");out.style.cssText = "font:12px ui-monospace,monospace;margin-top:6px;color:#6F8294";const show = () => {const d = chart.getData()[0] || {};out.textContent = "stage " + chart.getStage() +" · committed r=" + (d.r ?? 0).toFixed(2) + " spread=" + (d.spread ?? 0).toFixed(2);};chart.on("change", show); chart.on("stage", show); show();mount(out);