Tick
tick draws a line at a value on one axis, spanning the other axis. Over a category band it marks a value per category; with no band it spans the full extent, as a rug or strip plot. tickY and tickX force the value axis; tick infers it. inset shrinks each end, and length sets a fixed, centred length.
API reference
tick(options) · tickY(options) · tickX(options)
Import plot from elicitjs. tick infers the value axis from which axis is a band; tickY marks a value on y (spans the x band), tickX on x.
tick({ channels, orientation, inset, length, edits, id }) → Mark
tickY(options) → Mark // value on y
tickX(options) → Mark // value on x| Option | Type · default | Description |
|---|---|---|
channels | objectdefault{} | One band axis (span) + one linear axis (the marked value). See Channels. |
orientation | 'vertical' | defaultauto | Which axis the value runs along ( 'vertical' = y). Inferred from which axis is a band; tickY / tickX pin it. |
inset | numberdefault0 | Pixels to shrink each end of the span. |
length | number | Explicit centred span length in pixels. On a band axis it centres in the band; when the span axis also has a channel (e.g. scatter x+y), it centres on that channel’s encoded position so a short tick sits on the datum. |
edits | Edit[] | Mark-level edits; per-channel edits live in the channels map. |
stroke, | styledefaultstroke:'steelblue' | Style shorthands / channels. |
| Channel | Type | Description |
|---|---|---|
x | band | | Category (band) or value (linear), per orientation. |
y | band | | The other axis; the value axis carries edit: move() to drag the tick. |
stroke, | const | | Standard style surface. |
A mark emitting one line per datum (a bar with zero thickness).
A value marker across bands
tickY marks a y value across each category's band. It takes the same channels and edits as a bar, and drags the same way.
Ticks over a band axis
One tick per category, spanning the band at its y value.
const chart = Elicit({width: 380, height: 240,margins: { top: 14, right: 14, bottom: 26, left: 30 },data: [{ x: "A", y: 20 }, { x: "B", y: 45 },{ x: "C", y: 30 }, { x: "D", y: 60 },],schema: {x: { type: "categorical", domain: ["A", "B", "C", "D"] },y: { type: "quantitative", domain: [0, 100] },},marks: [tickY({stroke: "#50AEB7", strokeWidth: 3,channels: {x: { field: "x" },y: { field: "y" },},}),],});mount(chart.dom());
Drag a value (ticks)
Same y edit as a bar; pick: "nearest" grabs the tick from anywhere in its column.
const chart = Elicit({width: 380, height: 260,margins: { top: 14, right: 14, bottom: 26, left: 30 },data: [{ x: "A", y: 20 }, { x: "B", y: 45 },{ x: "C", y: 30 }, { x: "D", y: 60 },],schema: {x: { type: "categorical", domain: ["A", "B", "C", "D"] },y: { type: "quantitative", domain: [0, 100] },},marks: [tickY({stroke: "#50AEB7", strokeWidth: 3,channels: {x: { field: "x" },y: { field: "y",edit: move({ pick: "nearest" }) },},}),],});mount(chart.dom());
A rug / strip plot
With no band on the other axis, a tick spans the full extent, giving a strip of marks at each row's position. inset trims the ends so the strip sits clear of the frame.
tickX — a distribution strip
Values along x, each drawn as a vertical mark spanning y. inset shortens them.
const chart = Elicit({width: 400, height: 200,margins: { top: 16, right: 16, bottom: 28, left: 16 },data: [{ v: 12 }, { v: 18 }, { v: 21 }, { v: 34 }, { v: 39 },{ v: 41 }, { v: 55 }, { v: 58 }, { v: 63 }, { v: 71 }, { v: 84 },],schema: {v: { type: "quantitative", domain: [0, 100] },},marks: [tickX({stroke: "#1B3F60", strokeWidth: 2, inset: 10,channels: {x: { field: "v" },},}),],});mount(chart.dom());