Responsive sizing
By default an interface draws at the exact width / height you give it, in pixels (600×400 if unset). The responsive option makes it fit its parent instead. "scale" stretches one drawing to the container through a viewBox and keeps the aspect ratio. "reflow" redraws at native pixels on resize: text stays crisp, the width tracks the container, and the height stays fixed. responsive: true is the same as "reflow". In every mode, the width / height you pass is the design size.
API reference
Elicit({ responsive, width, height, … })
One option on the ElicitSpec. Everything else about a chart is unchanged — marks, edits and scales all read the (possibly resized) inner dimensions, so the whole scene reflows for free.
| Option | Type · default | Description |
|---|---|---|
responsive | 'fixed' | default'fixed' | 'fixed': draw at the pixel width/height. 'scale': viewBox, SVG fills the parent width (aspect kept). 'reflow' (or true): re-draw at the parent's measured width on resize. |
width / height | numberdefault600 / 400 | The design size — the exact pixels in "fixed", the viewBox in "scale", and the initial width + fixed height in "reflow". |
The same Chart. A "reflow" chart also wires a ResizeObserver; call chart.destroy() when you unmount it to detach the observer (a no-op in the other modes).
Scale (viewBox)
responsive: "scale" keeps the chart's 480×300 aspect ratio and stretches it to fill the column. Text and strokes scale with it. Use it when a chart should grow and shrink with its container, and text and strokes can scale too.
Fills the parent width
the same spec at responsive: "scale"; the SVG scales to this card via a viewBox.
const cats = ["A","B","C","D","E"];const chart = Elicit({width: 480, height: 300,responsive: "scale",margins: { top: 16, right: 12, bottom: 28, left: 34 },data: cats.map((c, i) => ({ cat: c, value: [30, 80, 45, 60, 20][i] })),schema: {cat: { type: "categorical", domain: cats },value: { type: "quantitative", domain: [0, 100] },},scales: { x: { type: "band" } },marks: [barY({ fill: "#50AEB7", channels: {x: { field: "cat" },y: { field: "value", edit: move() },} }),],});mount(chart.dom());
Reflow (ResizeObserver)
responsive: "reflow" redraws at native pixels to fit this card. The width tracks the container and the height stays 300. Resize the window and the bars lay out again at full sharpness. Call chart.destroy() on unmount.
Redraws to the parent width
responsive: "reflow"; drag a bar, then resize the window — layout recomputes.
const cats = ["A","B","C","D","E"];const chart = Elicit({width: 480, height: 300,responsive: "reflow",margins: { top: 16, right: 12, bottom: 28, left: 34 },data: cats.map((c, i) => ({ cat: c, value: [30, 80, 45, 60, 20][i] })),schema: {cat: { type: "categorical", domain: cats },value: { type: "quantitative", domain: [0, 100] },},scales: { x: { type: "band" } },marks: [barY({ fill: "#2B5D87", channels: {x: { field: "cat" },y: { field: "value", edit: move() },} }),],});mount(chart.dom());
Fixed (default)
With no responsive option, or responsive: "fixed", the chart below is exactly 320×240 pixels at any container width. Use it when a chart must be a precise size.
Exact pixels
the default: a 320×240 chart that ignores the parent width.
const cats = ["A","B","C","D","E"];const chart = Elicit({width: 320, height: 240,margins: { top: 16, right: 12, bottom: 28, left: 34 },data: cats.map((c, i) => ({ cat: c, value: [30, 80, 45, 60, 20][i] })),schema: {cat: { type: "categorical", domain: cats },value: { type: "quantitative", domain: [0, 100] },},scales: { x: { type: "band" } },marks: [barY({ fill: "#6F8294", channels: {x: { field: "cat" },y: { field: "value", edit: move() },} }),],});mount(chart.dom());