Stacked dots
dotStack draws a dot histogram: each row is one token, and tokens in the same slot stack into a countable column. Click an empty slot to add a token (create), and click a token to remove it (remove). The answer is the number of tokens in each slot: data.filter(d => d.bin === b).length.
API reference
dotStack(options) · dotStackY(options) · dotStackX(options)
Import plot from elicitjs. The category axis is a band/point scale over the discrete slots. dotStackY stacks upward (slots on x), dotStackX rightward (slots on y). Bare dotStack reads the direction from the channel map: the slot channel's axis is the category, and tokens stack along the other one.
dotStack({ channels, orientation, size, gap, ghost, label, edits, id }) → Mark| Option | Type · default | Description |
|---|---|---|
channels | objectdefault{} | A band/point category axis whose domain is the slot list. |
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' | defaultfrom the channel map | Which way tokens stack. dotStackY / dotStackX set it; otherwise it follows the positional channel you bound. Same option bar and waffle take. |
size | numberdefault7 | Token radius (fixed geometry — the stack offset is 2·size + gap per token). |
gap | numberdefault2 | Gap between stacked tokens, along the stack direction. |
ghost | booleandefaulttrue | Draw a faint open ring at each slot's next position (a droppable affordance). |
label | booleandefaultfalse | Draw the per-slot count above each column. |
| Channel | Type | Description |
|---|---|---|
x / y | band | | The category (slot) axis; the other axis is a pure count of stacked tokens. |
A mark emitting one circle per token, plus optional ghost rings and count labels.
Dropping tokens
Click to drop a token into the nearest slot. Click a token to take it back. count() caps the budget.
Probability tokens over bins
A discrete point scale of bins 0–1; 25-token budget.
const bins = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];const chart = Elicit({width: 560, height: 260,margins: { top: 20, right: 16, bottom: 28, left: 16 },axes: { x: {}, y: false },data: [{ bin: 0.3 }, { bin: 0.3 }, { bin: 0.3 },{ bin: 0.4 }, { bin: 0.4 }, { bin: 0.5 },],onChange: (d) => console.log("tokens:", d.length),schema: {bin: { type: "categorical", domain: bins },},scales: { x: { type: "point" } },constraints: [ count({ max: 25 }) ],marks: [dotStack({channels: { x: { field: "bin" } },edits: [ create({ gesture: "click", channels: ["x"] }), remove() ],label: true,}),],});mount(chart.dom());
Tentative dot on hover (probe)
create({ pick: "probe" }) shows the token before it is real; the click commits it.
const bins = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];const chart = Elicit({width: 560, height: 240,margins: { top: 16, right: 16, bottom: 28, left: 16 },axes: { x: {}, y: false },data: [],schema: {bin: { type: "categorical", domain: bins },},scales: { x: { type: "point" } },constraints: [ count({ max: 20, strategy: "reject" }) ],marks: [dotStack({id: "tokens",channels: { x: { field: "bin" } },edits: [// Hover previews the drop; the click commits it. advance:false keeps the// edit live so you can keep dropping tokens.create({ pick: "probe", channels: ["x"], advance: false, when: when.noAlt }),// The plane owns the pointer in probe mode, so removal picks the nearest.remove({ pick: "nearest", when: when.alt }),],}),],});mount(chart.dom());const out = document.createElement("div");out.style.cssText = "font:12px ui-monospace,monospace;color:#6F8294";const show = () => { out.textContent = "committed tokens: " + chart.getData().length + " / 20"; };chart.on("change", show); show();mount(out);
Per-slot cap with unique
unique({ field, max }) limits the height of any one column.
const cats = ["A","B","C","D"];const chart = Elicit({width: 420, height: 240,margins: { top: 16, right: 16, bottom: 28, left: 16 },axes: { x: {}, y: false },data: [{ bin: "A" }, { bin: "B" }, { bin: "B" }],schema: {bin: { type: "categorical", domain: cats },},scales: { x: { type: "band" } },constraints: [ unique({ field: "bin", max: 5, strategy: "reject" }) ],marks: [dotStack({channels: { x: { field: "bin" } },edits: [ create({ gesture: "click", channels: ["x"] }), remove() ],label: true,}),],});mount(chart.dom());
Orientation
Put the slots on y and tokens stack rightward instead of up. dotStackY and dotStackX force a direction. Bare dotStack takes it from the channels: the slot channel's axis holds the categories, and tokens stack along the other. orientation: "horizontal" | "vertical" sets it explicitly, as on bar and waffle.
Tokens that stack rightward
dotStackX with the slots on y; columns grow from the left edge.
const bins = ["never","rarely","sometimes","often","always"];const chart = Elicit({width: 460, height: 260,margins: { top: 16, right: 16, bottom: 28, left: 84 },data: [{ bin: "rarely" }, { bin: "rarely" }, { bin: "sometimes" },{ bin: "sometimes" }, { bin: "sometimes" }, { bin: "often" },],onChange: (d) => console.log("tokens:", d.length),schema: { bin: { type: "ordinal", domain: bins } },scales: { y: { type: "point" } },marks: [dotStackX({size: 8,fill: "#2B5D87",// The category is on y, so tokens stack along x.channels: { y: { field: "bin" } },edits: [ create({ gesture: "click", channels: ["y"] }), remove() ],}),],});mount(chart.dom());