Elicit.js

Symbol & Emoji

The symbol channel maps a category to a glyph, an emoji or a unicode shape, as fill maps a category to a colour. It is a channel, not a mark: point, dotStack and waffle draw the glyph in place of their circle or rect, and shape reads it as a named shape or SVG path. The elicited value is the category. Edit it with cycle() or edit.legend.category().

API reference

channels.symbol

A category โ†’ glyph map through an ordinal scale. Add it to any shape mark. Give it glyphs with scale: { range: [...] } or a named scale: { scheme: 'faces' }. Non-positional and non-invertible โ€” a drag can't set a glyph, so it's edited via cycle/legend/create.

symbol: { field, scale: { range | scheme }, edit? }
Options
OptionType ยท defaultDescription
scale.range
string[]defaultunicode shapes
The glyph palette. Defaults to โ—โ– โ–ฒโ—†โ˜…โ€ฆ when omitted.
scale.scheme
string
Named glyph set: 'faces', 'faces5', 'hearts', 'weather', 'arrows', 'shapes'.
size
numberdefaultmark default
The mark's radius still sets the glyph's px extent, so a glyph point and a circle point match.
Channels
ChannelTypeDescription
symbol
ordinal
Field โ†’ glyph. Range is a glyph array (scale: { range: ["๐Ÿ˜ข","๐Ÿ˜","๐Ÿ˜Š"] }) or a scheme.
Returns / emits

Nothing on its own โ€” it changes how a host mark draws each datum.

Emoji points โ€” click to cycle

Here the y position and the glyph both encode mood. A cycle() on the symbol channel advances the category on click. The face changes and the point moves to its new row, since both channels read the same field.

Mood over the week

symbol maps the ordinal mood to a face; cycle() advances it on click.

const chart = Elicit({
width: 380, height: 250,
margins: { top: 16, right: 16, bottom: 30, left: 64 },
data: [
{ day: "Mon", mood: "ok" }, { day: "Tue", mood: "good" },
],
schema: {
day: { type: "categorical", domain: ["Mon","Tue","Wed","Thu","Fri"] },
mood: { type: "ordinal", domain: ["bad","ok","good","great"] },
},
marks: [
point({
size: 15,
channels: {
x: { field: "day" },
y: { field: "mood" },
symbol: {
field: "mood",
scale: { range: ["๐Ÿ˜ข","๐Ÿ˜","๐Ÿ™‚","๐Ÿ˜„"] },
edit: cycle(),
},
},
}),
],
});
mount(chart.dom());
Try: Click a face to cycle its mood.

One fixed glyph โ€” no mapping

The symbol: 'โšฝ' shorthand draws one glyph on every point. It desugars to a constant channel and skips the scale, as fill: 'red' does. Here the elicited value is goals: drag a ball up or down to set that stage's total.

World Cup goals

A constant symbol: 'โšฝ' โ€” one glyph for every point, no scale. The elicited value is goals; drag a ball up or down to set it.

const chart = Elicit({
width: 420, height: 260,
margins: { top: 16, right: 16, bottom: 30, left: 40 },
data: [
{ stage: "Group", goals: 3 },
],
schema: {
stage: { type: "categorical", domain: ["Group","R16","QF","SF","Final"] },
goals: { type: "quantitative", domain: [0, 6] },
},
marks: [
point({
size: 15,
symbol: "โšฝ", // one glyph, no mapping โ€” pure identity
channels: {
x: { field: "stage" },
y: { field: "goals", edit: move() },
},
}),
],
});
mount(chart.dom());
Try: Drag a โšฝ up or down to change that stage's goals.

Emoji tokens โ€” drop and remove

A constant symbol shorthand makes every token the same glyph. create and remove work as on plain dots, here as a โญ star-rating counter.

Star tokens

dotStack of โญ tokens; click a slot to add, click a star to remove.

const chart = Elicit({
width: 380, height: 240,
margins: { top: 16, right: 16, bottom: 30, left: 30 },
data: [ { rating: 3 }, { rating: 3 }, { rating: 5 }, { rating: 4 } ],
schema: { rating: { type: "ordinal", domain: [1, 2, 3, 4, 5] } },
constraints: [ count({ max: 24 }) ],
marks: [
dotStack({
symbol: "โญ", size: 12,
channels: { x: { field: "rating" } },
edits: [ create({ gesture: "click", channels: ["x"] }), remove() ],
}),
],
});
mount(chart.dom());
Try: Click a column to add a โญ, click a โญ to remove it.

Emoji waffle โ€” count in glyphs

A symbol channel draws every waffle cell as its category's glyph, so you count a quantity in ๐ŸŽ. Drag to fill. Empty cells draw faint and stay grabbable.

Fruit basket

Each category's cells render its emoji; edit.waffle.fill drags the count.

const chart = Elicit({
width: 380, height: 280,
margins: { top: 16, right: 16, bottom: 30, left: 30 },
data: [
{ fruit: "apples", n: 6 },
],
schema: {
fruit: { type: "categorical", domain: ["apples","bananas","cherries"] },
n: { type: "quantitative", domain: [0, 12] },
},
constraints: [ snap({ step: 1 }) ],
marks: [
waffleY({
channels: {
x: { field: "fruit" },
count: { field: "n", edit: edit.waffle.fill() },
symbol: { field: "fruit", scale: { range: ["๐ŸŽ","๐ŸŒ","๐Ÿ’"] } },
},
}),
],
});
mount(chart.dom());
Try: Drag up a column to change its count.

A glyph legend / picker

legendSymbol({ edit: edit.legend.category() }) draws a row of glyphs you click to set the category. It is the same legend as a colour legend, drawn with glyphs instead of swatches.

Pick a weather

A single-row answer whose glyph is set from the legend row.

const chart = Elicit({
width: 360, height: 240,
margins: { top: 16, right: 16, bottom: 16, left: 16 },
data: [ { sky: "cloudy" } ],
schema: { sky: { type: "ordinal", domain: ["sunny","partly","cloudy","rain","storm"] } },
axes: false,
marks: [
point({
size: 40,
channels: {
x: { value: 60 }, y: { value: 100 },
symbol: { field: "sky", scale: { scheme: "weather" } },
},
}),
// A glyph legend that doubles as a picker: legendSymbol draws the row of
// glyphs, edit.legend.category() makes each one click-to-set the category.
legendSymbol({ anchor: "bottom", swatchSize: 22, edit: edit.legend.category() }),
],
});
mount(chart.dom());
Try: Click a glyph in the legend to set today's weather.