Elicit.js

Mobile & touch

Every chart works with a finger as well as a mouse. You turn nothing on: the same edits run, and a few things adapt so a finger can use them. This page lists what changes and what a phone can't do.

Ready for a phone

responsive: "scale" fits the screen; small points with move() and a crosshair.

const chart = Elicit({
width: 360, height: 240,
responsive: "scale",
margins: { top: 14, right: 14, bottom: 28, left: 36 },
schema: {
hours: { type: "quantitative", domain: [0, 12] },
score: { type: "quantitative", domain: [0, 100] },
},
data: [
{ hours: 2, score: 35 }, { hours: 4, score: 52 },
{ hours: 7, score: 68 }, { hours: 10, score: 81 },
],
guides: [guides.crosshair({ format: ".0f" })],
marks: [
point({
fill: "#EE7B5E", size: 5,
channels: { x: { field: "hours" }, y: { field: "score" } },
edits: [move({ channels: ["x", "y"] })],
}),
],
});
mount(chart.dom());
Try: On a phone: press near a point to read it · drag it · swipe beside the chart to scroll.

Fit the screen

A phone is narrow. Set responsive: "scale" or "reflow" so the chart fits the screen instead of running off its edge. See Responsive sizing.

Grabbing small marks

On a touch screen, each small editable mark gets an invisible target about 44px across: points, handles, thin bars, lines and curves. The mark under your finger wins; otherwise the nearest one within reach does. Large marks and text keep their own size.

A tap may wobble up to 10px and still count as a tap, so cycle, toggle and click-to-add work with a finger.

In a dense chart, a tap near a mark takes that mark rather than the empty space beside it.

Scrolling past a chart

A drag that starts on an editable mark edits it, and the page holds still. So does a drag on the plot of a chart with a plane gesture (draw, sweep, nearest, probe). A swipe anywhere else scrolls the page.

A full-screen chart with a plane gesture leaves nowhere to scroll from. Keep it shorter than the screen, or leave a margin beside it.

No hover

A finger has no hover. Tips and the crosshair show while your finger is on the chart and hide when you lift it, so press a mark to read it. Set touch: false on guides.tip or guides.crosshair to show it only for a mouse.

A probe previews while you drag and settles when you lift. A tap settles at once.

What a phone can't do

  • An edit gated on a key, such as when: when.shift, can't be reached. Don't gate an edit a phone user needs.
  • Wheel zoom (edit.view.zoom) needs a wheel. There is no pinch to zoom.
  • Arrow-key nudging needs a keyboard.

A double tap counts as a double click, so dblclick edits still work.