⚠ Early release: v0.3.2.sophistry is not ready for production use. Until 1.0, any minor release may break the API; expect missing features and bugs too.Stability and versioning
Chart catalogue
Every chart in @sophistry/charts: 73 2D definitions, plus the eight 3D charts of @sophistry/charts/3d (below). The table uses the component names from @sophistry/solidjs/charts (and @sophistry/react/charts); the definition behind each is the same name in lower camel case (Chart is chart, Hist2D is hist2d), except Regression, whose definition is regressionPlot.
“Needs” lists the props with no default (beyond data); every chart also takes progress, zIndex and visible, and most take opacity. The Charts guide explains the model and Chart animation the transitions; each definition’s full props come with its types, in your editor (see API).
| Component | Needs | Notable options |
|---|---|---|
Chart |
width, height |
xRange, yRange, xAxis / yAxis (scale, categories, slot, zero, nice, position, zeroLine, numberHalo, tick options), y2Range / y2Axis / y2Label (with SecondaryY; y2Axis.alignTicks), x2Range / x2Axis / x2Label (with SecondaryX), autosize ("fit", "contain", "pad"), grid, title, subtitle, xLabel, yLabel, color (domain, range, label), legend, legendTitle, sizeLegend, colorbar, colorbarLabel, clip, reveal, tooltip |
Facet |
data, width, height, panel (a function of the panel returning nodes) |
row, column, rows / columns (order), wrap, scales ("shared", "independent", per axis), gap, widths / heights (ratios), space ("free"), to, panelTitle, marginTitles, rowTitle, xLabel, yLabel, title, color, legend ("right", "top"), sizeLegend, colorbar, autosize, stagger, plus the panels’ xRange, yRange, axis / xAxis / yAxis, grid, clip, reveal |
ChartLink |
x (default on), y, xRange, yRange, color |
|
RangeBrush |
from, to (tracks), or x/y pairs (a box) |
axis, bounds, minSpan, snap (band axes), wheel, wheelSpeed, handles, disabled, color, fillOpacity, label (inside a Chart) |
ChartZoom |
x and/or y (track pairs) |
bounds, minSpan, wheel ("zoom", "pan", false), pan, dragMode ("pan", "box"), onDragModeChange, toolbar, boxZoom, snap (band axes), zoomSpeed, step, zoomStep, disabled, label (inside a Chart) |
SecondaryY / SecondaryX |
(inside a Chart; see y2Range, y2Axis, y2Label / x2Range, x2Axis, x2Label) |
|
PairPlot |
data, variables, width, height |
variableLabels, series, key, diag ("density", "histogram", false), binCount, corner, radius, offDiagonal (a function of the panel returning nodes), gap, widths, heights, space, axis, grid, color, legend ("top"), title, autosize, stagger |
JointPlot |
data, x, y, width, height |
series, key, marginal ("density", "histogram"), binCount, commonNorm, ratio, space, radius, xRange, yRange, xAxis, yAxis, xLabel, yLabel, color, legend ("top"), autosize, children (more layers on the scatter) |
Legend |
entries, at |
direction, title, fontSize, maxWidth, progress |
Colorbar |
domain, at |
ramp, orientation, length, thickness, label, scale, base, midpoint, ticks, tickFormat, progress |
SizeLegend |
scale, at |
values, format, direction, title, fontSize, maxWidth, progress |
Breadcrumbs |
path |
root, x, y, align, fontSize, separator, maxWidth, ellipsis, back, color, linkColor, onSelect (the trail a drill-down hierarchy draws with breadcrumbs, on its own) |
TooltipOverlay |
state |
area, active, pointer, view (the panel a chart draws its tooltips on; a chart makes its own, so this is for custom frames) |
Bars |
value* |
category, series, key, layout ("overlay", "stack", "dodge"), offset, order, orientation, base, subband, reveal ("grow", "stack", "fade"), labels, stagger, staggerOrder, to / blend / staging, enterStagger, tooltip, color, colors (inside a Chart), transition |
RuleX / RuleY |
x* / y* |
y1, y2 / x1, x2, color, dash, transition |
TickX / TickY |
x* / y* |
y / x (row or column), length, transition |
Rug |
value* |
series, key, axis ("x" or "y"), length, color, stagger, transition |
Density |
x* |
series, commonNorm, orientation, bandwidth, samples, domain, row, rowHeight, rowScale, color, fillOpacity, reveal ("x", "grow") |
Strip |
value* |
category, series, dodge, key, orientation, width, jitterKey, seed, radius, color, stagger, staggerOrder, enterStagger, tooltip, transition |
Beeswarm |
value* |
category, series, dodge, key, orientation, radius, gap, side, color, stagger, staggerOrder, enterStagger, tooltip, transition |
Regression |
x***, y* |
series, method ("linear", "poly", "loess"), degree, bandwidth, robust, level, samples, color, bandOpacity |
Rects |
x1, x2, y1, y2, color, fillOpacity, transition |
|
Cells |
x, y |
value, ramp, rampMin, rampMax, rampScale, rampMidpoint, labels, inset, transition |
Dendrogram |
tree, categories |
axis, side, size, gap, color, strokeWidth, stagger (inside a Chart) |
Labels |
x***, y*, text* |
direction, gap, fontSize, color |
Links |
x1, y1, x2, y2 |
arrow, color |
Vectors |
x, y, u, v |
scale, color |
Candlestick |
x, open, high, low, close |
ohlc, upColor, downColor, bodyWidth (inside a Chart) |
Heatmap |
x, y, value, width, height |
columns, rows, ramp, rampMin, rampMax, rampScale, rampMidpoint, labels, title, cluster (true, "rows", "columns"), linkage, metric, dendrogram, dendrogramSize |
Waterfall |
value*, width, height |
label, total, labels, connectors, upColor, downColor, totalColor |
Funnel |
value*, width, height |
label, show, connectors, padding |
Treemap |
data (root), value, width, height |
children, label, tile, padding, paddingTop, sort, focus, drill, onFocusChange, breadcrumbs, to + blend, enterStagger |
Icicle |
data (root), value, width, height |
children, label, orientation, root, focus, drill, onFocusChange, breadcrumbs, to + blend, enterStagger |
Sunburst |
data (root), value, radius |
children, label, center, root, focus, drill, onFocusChange, breadcrumbs, to + blend, enterStagger |
CirclePack |
data (root), value, radius |
children, label, center, padding, focus, drill, onFocusChange, breadcrumbs, to + blend, enterStagger |
Tree |
data (root), width, height |
children, label, layout ("tidy", "cluster"), link ("curve", "elbow"), orientation ("horizontal", "vertical", "radial"), distance, nodeRadius, value, focus, drill, onFocusChange, breadcrumbs, to + blend, enterStagger |
Sankey |
source, target, value, width, height |
nodes, nodeId, nodeLabel, align, nodeWidth, nodePadding, linkColor |
Chord |
source, target, value |
nodes, nodeId, nodeLabel, center, radius, thickness, padAngle, directed, arrows, arrowSize, ribbonColor, ribbonOpacity |
ParallelCoordinates |
axes, width, height |
color, colors, opacity |
Gauge |
value, radius |
min, max, bands, needle, unit, label, startAngle, endAngle |
Bullet |
value*, width, height |
target, ranges, label, min / max, sharedScale, rangeColors, barSize, ticks |
Waffle |
value* |
label, rows, columns, legend, legendPosition |
Mosaic |
x, y, width, height |
value (default: count), columns / rows (order), padding, colors / color, labels, columnLabels, shares, stagger, tooltip |
RadialBarChart |
value*, radius |
label, series, maxValue, sweep, innerRadius |
BarChart |
value*, width, height |
label, color, colors, yRange, center, barWidth, yAxis |
BoxPlot |
values**, width, height |
label, series, legend, yRange, boxWidth, whiskerScale, stagger |
ViolinPlot |
values**, width, height |
label, series, legend, bandwidth, samples, scale, median, stagger |
PieChart |
value* |
label, key, ariaLabel, center, radius, innerRadius (doughnut), startAngle, clockwise, labels, reveal ("grow", "sweep") |
PolarAreaChart |
value* |
label, key, series, ariaLabel, center, radius, maxValue, stagger |
RadarChart |
axisValues** |
series, key, axisLabels, maxValue, gridRings, fillOpacity, labelGap, reveal ("grow", "sweep"), stagger, staggerOrder, enterStagger |
LinePlot |
x***, y* |
series, curve, reveal, to / blend / staging, enterStagger, shape props (stroke, dash, …) |
Scatter |
x***, y* |
series, key, radius, size / sizeRange / sizeMaxValue, symbol, color, stagger, staggerOrder, to / blend / staging, enterStagger, time / at / trail / timeFade, transition |
Stem |
x***, y* |
series, key, baseline, markerRadius, color, stagger, staggerOrder, enterStagger, transition |
ErrorBar |
x***, y* |
yError, xError, series, key, capSize, markerRadius, stagger, staggerOrder, enterStagger, transition |
FillBetween |
x***, y1* |
y2 (default: baseline), series, curve, reveal |
StackPlot |
x***, y (one channel per band, or one with a series) |
series, colors, baseline, offset ("zero", "normalize", "center", "wiggle"), order, curve, reveal, to / blend / staging, enterStagger |
Stairs |
value* |
edges (length n + 1), series, reveal |
Ecdf |
value* |
series, pad, reveal |
Histogram |
value* |
binCount, range (step = bin width), color, fillOpacity, stagger, to / blend / staging (toBinCount, toRange), enterStagger, transition |
Hist2D |
x, y |
xBins, yBins, xRange, yRange, ramp, rampScale, stagger, transition |
HexBin |
x, y, radius |
ramp, rampScale, stagger |
Imshow |
values |
xRange, yRange, rowOrigin, ramp, rampMin, rampMax, rampScale, rampMidpoint, stagger |
Pcolormesh |
xs, ys, values |
ramp, rampMin, rampMax, rampScale, rampMidpoint, stagger, transition |
Contour |
xs, ys, values |
levels (list or count), ramp, rampScale, rampMidpoint, stagger |
ContourF |
xs, ys, values |
levels, ramp, rampScale, rampMidpoint, stagger |
Tripcolor |
x, y, value |
triangles, ramp, rampMin, rampMax, rampScale, rampMidpoint, stroke (mesh) |
TriContour / TriContourF |
x, y, value |
triangles, levels, ramp, rampScale, rampMidpoint |
EventPlot |
events** |
color, colors, lineOffset, lineLength, stagger |
Barbs |
function |
length, barbSpacing, barbLength |
* optional when data is number[]. ** optional when data is number[][]. *** optional when data is number[] (defaults to the index). Barbs samples a function field rather than taking data.
Every mark with a key or series also takes to, blend and staging (data transitions), whether or not its row lists them. transition is the clock-driven update of the per-datum marks.
Every chart is batched: per-datum marks draw as one instances node, marks with distinct outlines (lines, areas, wedges, ribbons, bands) as one path batch, and Imshow on linear axes as one image. There is no rendering option. See Batched by default.
BarChart is the preset; <Bars> inside a <Chart> does the rest. orientation="horizontal" lays bars along a category y axis, base makes them float, and layout="stack" or "dodge" arranges them by series. Under a stack, negative values stack down from zero (diverging bars) and offset="normalize" makes 100% bars. labels writes each value past its bar, or inside it with labels={{ position: "inside" }}, hiding any that don’t fit; total: true adds stack totals. barChartHandle(node) (and barsHandle(node) for <Bars>) gives barBounds(i) for annotating a bar.
Bar chart reveal
A bar chart whose bars grow in as draw() drives its progress.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { BarChart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
export default function BarChartReveal() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 1.5 })); });
return ( <Stage units={10}> <BarChart data={[3, 7, 4, 9, 6]} label={(_, i) => "abcde"[i]} yRange={[0, 10, 2]} width={8} height={4} progress={progress} /> </Stage> );}Grouped and stacked bars
One long-format table, two layouts of one bar mark: series colours the regions through the chart's scale and legend, the dodge layout puts them side by side in each quarter, the stack layout piles them up. The stack grows as one, so every frame is a true stacked chart.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { Bars, Chart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const sales = ["Q1", "Q2", "Q3", "Q4"].flatMap((quarter, q) => ["north", "south", "east"].map((region, r) => ({ quarter, region, units: [ [4, 6, 5, 8], [3, 3, 4, 5], [2, 4, 3, 4], ][r][q], })),);const palette = ["#4c78a8", "#f58518", "#54a24b"];
export default function GroupedAndStackedBars() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={16}> <Chart width={6} height={4} center={{ x: -4, y: 0 }} grid="y" color={{ range: palette }} legend="top" progress={shown} > <Bars data={sales} category="quarter" value="units" series="region" layout="dodge" stagger={0.4} /> </Chart> <Chart width={6} height={4} center={{ x: 4, y: 0 }} grid="y" color={{ range: palette }} legend="top" progress={shown} > <Bars data={sales} category="quarter" value="units" series="region" layout="stack" /> </Chart> <Text text="dodge" x={-4} y={-3.2} fontSize={0.4} /> <Text text="stack" x={4} y={-3.2} fontSize={0.4} /> </Stage> );}Diverging stacked bars
A Likert chart from long-format rows: series="answer" with layout="stack" sends negative values down from zero and positive values up, so disagreement and agreement grow apart from one centre line, and the chart's colour scale gives the legend in answer order. The question axis stands at the left edge, clear of the bars, and a zero line marks the baseline they grow from.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Bars, Chart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const answers = ["strongly disagree", "disagree", "agree", "strongly agree"];const sign = [-1, -1, 1, 1];const survey = [ { q: "Clear docs", counts: [4, 10, 38, 22] }, { q: "Fast builds", counts: [12, 20, 25, 9] }, { q: "Easy setup", counts: [6, 14, 30, 18] },].flatMap(({ q, counts }) => counts.map((n, a) => ({ q, answer: answers[a], share: sign[a] * n })),);const palette = ["#ca0020", "#f4a582", "#92c5de", "#0571b0"];
export default function DivergingBars() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2 })); });
return ( <Stage units={12}> <Chart // "contain": width × height holds everything — the question // names on the left, the numbers below, the legend on top — so // the chart is simply centred on the stage. width={10.4} height={4.8} autosize="contain" xRange={[-40, 60, 20]} xAxis={{ tickFormat: (v) => `${Math.abs(v)}` }} // The question axis is a band axis, so it stands at the left // edge (not at zero, mid-chart), and the frame draws a zero // line for the bars to grow from. The domain pins the legend // to answer order and the range gives the diverging colours. color={{ domain: answers, range: palette }} legend="top" progress={shown} > <Bars data={survey} category="q" value="share" series="answer" orientation="horizontal" // Inner answers first, so each side stacks outward from zero. layout="stack" order={["disagree", "strongly disagree", "agree", "strongly agree"]} tooltip={(d) => `${d.answer}: ${Math.abs(d.share)}`} /> </Chart> </Stage> );}Value labels in stacked bars
labels={{ position: "inside", total: true }} centres each segment's value in it, in whichever of dark and light text reads on its fill, and writes each stack's total past its end. Labels count up and grow in with their segments; one too small for its segment (the 1 in Q2) is left out.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Bars, Chart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const sales = ["Q1", "Q2", "Q3", "Q4"].flatMap((quarter, q) => ["north", "south", "east"].map((region, r) => ({ quarter, region, units: [ [4, 6, 5, 8], [3, 1, 4, 5], [2, 4, 3, 4], ][r][q], })),);
export default function StackedBarLabels() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.5} grid="y" color={{ range: ["#1f3b73", "#f58518", "#c9e3b2"] }} legend="top" progress={shown} > <Bars data={sales} category="quarter" value="units" series="region" layout="stack" labels={{ position: "inside", total: true }} stagger={0.4} /> </Chart> </Stage> );}Distributions
Section titled “Distributions”Density draws a kernel density estimate; with series, one curve per category, and with row, each on its own ridgeline row. commonNorm scales curves by their share of the data. orientation="horizontal" turns it on its side, as <JointPlot>’s marginals do. Rug puts a tick at every raw value.
Density with a rug
One kernel density estimate per series (morning and evening waits, from one long-format sample), both sweeping in along x behind one front, with the raw sample as a rug of ticks standing on the axis, in the same series colours, drawn in value order.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Density, Rug } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// Two overlapping clusters, from a deterministic sine hash.const waits = Array.from({ length: 80 }, (_, i) => { const u = (Math.sin((i + 1) * 12.9898) + Math.sin((i + 1) * 78.233)) / 2; return i % 3 === 0 ? { when: "evening", minutes: 7.5 + u * 1.5 } : { when: "morning", minutes: 3.5 + u * 1.8 };});
export default function DensityAndRug() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4} xLabel="minutes" grid="y" legend="top" progress={shown} > <Density data={waits} x="minutes" series="when" /> <Rug data={waits} value="minutes" series="when" stagger={0.6} /> </Chart> </Stage> );}Ridgeline
One Density over long-format rows, with series="month" and row: each month's curve stands on its own row of a band y axis and rises into the one above, so the shift in the distribution month by month reads as a landscape. The month axis stands at the left edge, clear of the curves, though the temperatures cross zero, and reveal="x" uncovers every ridge behind one shared front.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Density } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const months = ["Jan", "Mar", "May", "Jul", "Sep", "Nov"];// Daily highs in °C for a continental climate: winter months straddle zero.const centre = [-4, 3, 15, 24, 16, 2];// A deterministic, roughly bell-shaped sample around each month's centre.const rows = months.flatMap((month, m) => Array.from({ length: 60 }, (_, i) => { let sum = 0; for (let k = 1; k <= 3; k++) sum += Math.sin((i + 1) * k * 12.9898 + m * 4.1); return { month, temp: centre[m] + sum * 2.5 }; }),);const palette = [ "#4c78a8", "#72b7b2", "#54a24b", "#eeca3b", "#f58518", "#b279a2",];
export default function Ridgeline() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.5} xLabel="°C" // One clip front sweeps left to right across every ridge. reveal="x" // The rows already name the months, so no legend. color={{ domain: months, range: palette }} legend={false} progress={shown} > <Density data={rows} x="temp" series="month" row rowHeight={1.5} fillOpacity={0.6} /> </Chart> </Stage> );}Strip spreads dots across a band by seeded jitter, so scrubbing never reshuffles them; Beeswarm packs them without overlap. dodge gives each series its own sub-band.
Strip plot and beeswarm
Every observation as a dot, coloured by cohort through the chart's series scale and legend. A strip plot spreads them by seeded jitter (the same on every frame); a beeswarm packs them so none overlap. Dots appear in place, low values first.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { Beeswarm, Chart, Strip } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const arms = ["placebo", "low dose", "high dose"];const trials = arms.flatMap((arm, a) => Array.from({ length: 30 }, (_, i) => { const u = (Math.sin((i + 1) * 12.9898 + a * 7.1) + Math.sin((i + 1) * 4.1414)) / 2; const cohort = i % 3 === 0 ? "2025" : "2024"; return { arm, cohort, response: 40 + a * 8 + u * 12 }; }),);
export default function StripAndSwarm() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={16}> <Chart width={6} height={4} center={{ x: -4, y: 0 }} grid="y" legend="top" progress={shown} > <Strip data={trials} category="arm" value="response" series="cohort" stagger={0.6} /> </Chart> <Chart width={6} height={4} center={{ x: 4, y: 0 }} grid="y" legend="top" progress={shown} > <Beeswarm data={trials} category="arm" value="response" series="cohort" radius={0.06} stagger={0.6} /> </Chart> <Text text="Strip" x={-4} y={-3.2} fontSize={0.4} /> <Text text="Beeswarm" x={4} y={-3.2} fontSize={0.4} /> </Stage> );}Keyed beeswarm update
Week 1 to week 6 of a trial on one blend track: participants who drop out shrink away, everyone else slides from their place in the first swarm to their place in the second (both ends packed), then a new arm's band opens and its dots grow in.
5 collapsed lines
import { okabeIto } from "@sophistry/charts";import { hold, sequence, track, valueTo } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Beeswarm, Chart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
/** A participant's own spread around their arm's mean, the same every week. */const spread = (id: number) => Math.sin(id * 12.9898) * 14;const effect: Record<string, number> = { placebo: -2, "low dose": -10 };const week1 = Array.from({ length: 40 }, (_, id) => ({ id, arm: id % 2 ? "low dose" : "placebo", score: 50 + spread(id),}));const week6 = [ // Every seventh participant drops out; the rest move by their arm's effect. ...week1 .filter((d) => d.id % 7 !== 3) .map((d) => ({ ...d, score: d.score + effect[d.arm] })), ...Array.from({ length: 16 }, (_, k) => ({ id: 100 + k, arm: "high dose", score: 34 + spread(100 + k), })),];
export default function KeyedBeeswarm() { const { play } = usePlayer(); const blend = track(0); onSettled(() => { // Staged transitions ease each stage themselves: drive them linearly. void play( sequence(hold(0.6), valueTo(blend, 1, { duration: 3, easing: "linear" })), ); });
return ( <Stage units={12}> <Chart width={10} height={4.4} grid="y" // Pad the fitted range so the lowest dots clear the axis line. yAxis={{ margin: 0.05 }} yLabel="score" legend={false} color={{ range: okabeIto, domain: ["placebo", "low dose", "high dose"], }} > <Beeswarm data={week1} to={week6} blend={blend} key="id" category="arm" value="score" series="arm" radius={0.09} /> </Chart> </Stage> );}Regression fits a line, polynomial or LOESS smooth (robust resists outliers) and shades its confidence band (level, 0.95 by default).
Regression with a confidence band
One least-squares fit per series, each with the 95% band of its mean, narrowest at the centre of its data. The series channel splits the fits and colours fits and points alike, keyed by one legend; every line and band sweeps in along x behind one front.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Regression, Scatter } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const students = Array.from({ length: 24 }, (_, i) => { const online = i >= 12; const hours = 1 + (i % 12) * 0.7 + (online ? 0.3 : 0); const noise = Math.sin((i + 1) * 12.9898) * 5; return online ? { course: "online", hours, score: 40 + hours * 5.5 + noise } : { course: "lecture", hours, score: 52 + hours * 3.5 + noise };});
export default function RegressionBand() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.2} // The top legend and the y title sit above height: leave them room. center={{ x: 0, y: -0.4 }} xLabel="hours" yLabel="score" grid="y" legend="top" progress={shown} > <Regression data={students} x="hours" y="score" series="course" /> <Scatter data={students} x="hours" y="score" series="course" stagger={0.5} /> </Chart> </Stage> );}Lines, scatter and error bars
Section titled “Lines, scatter and error bars”ErrorBar takes yError and xError as one magnitude or a [low, high] pair. Scatter’s radius is in scene units; size maps a value through a square-root scale so each marker’s area tracks it. LinePlot, FillBetween and StackPlot take curve: "linear", "monotone" (smooth, never overshoots: the safe choice for data), "natural", "catmull-rom", or the "step" variants.
Scatter with error bars
Measurements as points with a symmetric error bar on each: every point fades in where it stands and its bar grows out of it, left to right.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Axes, Stage, usePlayer } from "@sophistry/solidjs";import { ErrorBar, Scatter } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const measurements = [ { x: 1, y: 2.1, err: 0.5 }, { x: 2, y: 3.4, err: 0.8 }, { x: 3, y: 3.9, err: 0.4 }, { x: 4, y: 5.2, err: 0.9 }, { x: 5, y: 5.6, err: 0.6 }, { x: 6, y: 7.1, err: 0.7 },];
export default function ScatterWithErrorBars() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={12}> <Axes xRange={[0, 7, 1]} yRange={[0, 10, 2]} width={9} height={5}> <ErrorBar data={measurements} x="x" y="y" yError="err" progress={progress} stagger={0.5} /> <Scatter data={measurements} x="x" y="y" radius={0.12} progress={progress} stagger={0.5} /> </Axes> </Stage> );}Line and area curves
The same readings drawn three ways: a monotone curve (smooth, but never overshooting a reading) over a monotone band, a straight polyline, and a step-after line that holds each value until the next. Curves are native Béziers, and the reveal cuts them along x without straightening them.
9 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, FillBetween, LinePlot, Scatter,} from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const readings = [3, 3.2, 7.5, 8, 4, 4.2, 6.8, 2.5, 3, 6].map( (level, hour) => ({ hour, level, }),);const shifted = (by: number) => readings.map((r) => ({ hour: r.hour, level: r.level + by }));const linear = shifted(-1.5);const steps = shifted(-3);
export default function LineCurves() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 3 })); });
return ( <Stage units={12}> <Chart width={8} height={4.4} xLabel="hour" yRange={[-2, 10, 2]} grid="y" legend="top" // The top legend sits above height: leave it room. center={{ x: 0, y: -0.3 }} progress={shown} > <FillBetween data={readings} x="hour" y1={(r) => r.level + 0.8} y2={(r) => r.level - 0.8} curve="monotone" /> {/* A constant series per layer names each curve in the legend. */} <LinePlot data={readings} x="hour" y="level" series={() => "monotone"} curve="monotone" /> <LinePlot data={linear} x="hour" y="level" series={() => "linear"} /> <LinePlot data={steps} x="hour" y="level" series={() => "step-after"} curve="step-after" /> <Scatter data={readings} x="hour" y="level" radius={0.06} /> </Chart> </Stage> );}Histograms
Section titled “Histograms”Histogram buckets raw values by binCount, or by a range whose step is the bin width ([0, 10, 2] is five bins). To re-bin across a transition, give the far end toBinCount or toRange.
Histogram bins
The same 120 samples regrouped into more and more bins, from coarse to fine.
4 collapsed lines
import { derive, track, valueTo } from "@sophistry/core";import { Axes, Stage, Text, usePlayer } from "@sophistry/solidjs";import { Histogram } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// 120 bell-shaped samples in [0, 6]: each is the sum of six uniform numbers from a tiny generator.let seed = 7;const uniform = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647;};const samples = Array.from({ length: 120 }, () => Array.from({ length: 6 }, uniform).reduce((a, b) => a + b),);
export default function HistogramBins() { const { play } = usePlayer(); const bins = track(4);
onSettled(() => { void play(valueTo(bins, 20, { duration: 4 })); });
return ( <Stage units={14}> <Axes xRange={[0, 6, 1]} yRange={[0, 70, 10]} width={10} height={5}> <Histogram data={samples} binCount={derive(bins, Math.round)} range={[0, 6]} /> </Axes> <Text text={derive(bins, (value) => `${Math.round(value)} bins`)} y={3.5} /> </Stage> );}Box and violin plots
Section titled “Box and violin plots”Both take one datum per group holding its raw sample in values. BoxPlot draws quartiles, whiskers at 1.5 IQR and outliers; ViolinPlot draws a kernel density with a median mark. With series and label, groups sharing a name stand side by side.
Box and violin plots
The same three samples summarised two ways: quartile boxes that open out of their medians, and kernel-density violins that widen out of their centre lines.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { BoxPlot, ViolinPlot } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// Deterministic, roughly bell-shaped samples: sums of a few sine-hash "uniforms".const sample = (seed: number, center: number, spread: number, n = 60) => Array.from({ length: n }, (_, i) => { let sum = 0; for (let k = 1; k <= 4; k++) { sum += (Math.sin((i + 1) * k * 12.9898 + seed * 78.233) + 1) / 2; } return center + (sum - 2) * spread; });
const groups = [ { name: "control", values: sample(1, 5, 2) }, { name: "dose A", values: [...sample(2, 7, 1.5), 12.5] }, { name: "dose B", values: sample(3, 6, 3) },];
export default function BoxAndViolin() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={16}> <BoxPlot data={groups} values="values" label="name" yRange={[0, 14, 2]} width={6} height={4.2} center={{ x: -4.2, y: 0 }} progress={progress} stagger={0.4} /> <ViolinPlot data={groups} values="values" label="name" yRange={[0, 14, 2]} width={6} height={4.2} center={{ x: 4.2, y: 0 }} progress={progress} stagger={0.4} /> <Text text="BoxPlot" x={-4.2} y={-3.2} fontSize={0.4} /> <Text text="ViolinPlot" x={4.2} y={-3.2} fontSize={0.4} /> </Stage> );}Grouped box plots
Box plots split by a series, seaborn's hue: the boxes sharing a dose stand side by side in its slot, and a dodged strip of the raw readings sits over each box. One colour scale and one legend serve both.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { BoxPlot, Strip } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const doses = ["low", "mid", "high"];const arms = ["placebo", "drug"];// Raw readings: 14 per dose and arm, from a deterministic sine hash.const readings = doses.flatMap((dose, d) => arms.flatMap((arm, a) => Array.from({ length: 14 }, (_, i) => ({ dose, arm, score: 40 + a * (6 + 6 * d) + 9 * Math.sin((i + 1) * (d + 2) * (a + 3) * 1.7), })), ),);// The same readings, one sample per box.const groups = doses.flatMap((dose) => arms.map((arm) => ({ dose, arm, scores: readings .filter((r) => r.dose === dose && r.arm === arm) .map((r) => r.score), })),);
export default function GroupedBoxes() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <BoxPlot data={groups} values="scores" label="dose" series="arm" fillOpacity={0.35} width={7} height={4.2} center={{ x: -0.6, y: 0 }} yRange={[20, 80, 10]} stagger={0.4} progress={shown} > <Strip data={readings} category="dose" value="score" series="arm" dodge width={0.5} radius={0.045} /> </BoxPlot> </Stage> );}Pie, polar area and radar
Section titled “Pie, polar area and radar”All three sit at center with radius. innerRadius makes a doughnut; ariaLabel names each slice for assistive technology. RadarChart draws one polygon per datum against shared axes; set maxValue to keep the scale fixed while data changes. A radar’s transition joins its axes by name, so an axis can fold in or out.
Pie and radar charts
A doughnut chart and a two-series radar chart, both built from plain data and revealed together: the doughnut's slices open together from 12 o'clock, each pushed round by the ones before, while the radar's polygons grow out of the centre. ariaLabel gives each slice an accessible name.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { PieChart, RadarChart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const share = [ { name: "Solid", pct: 42 }, { name: "Svelte", pct: 23 }, { name: "Vue", pct: 20 }, { name: "Other", pct: 15 },];
const skills = [ { who: "Ada", scores: [8, 5, 7, 9, 6] }, { who: "Grace", scores: [6, 9, 5, 7, 8] },];
export default function PieAndRadar() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={14}> <PieChart data={share} value="pct" label="name" ariaLabel="Framework share" center={{ x: -3.6, y: 0.2 }} radius={2.2} innerRadius={1} progress={progress} /> <RadarChart data={skills} axisValues="scores" axisLabels={["Speed", "Craft", "Docs", "Tests", "Design"]} maxValue={10} center={{ x: 3.6, y: 0.2 }} radius={2.2} progress={progress} /> <Text text="doughnut" x={-3.6} y={-3.1} fontSize={0.4} /> <Text text="radar, two series" x={3.6} y={-3.1} fontSize={0.4} /> </Stage> );}Radar with a changing axis set
Two phones rated on five axes, then on a new set of five. Axes are matched by name: Weight and Price fold away, every polygon's corner on them flattening into its edge, the shared axes turn to their new places, then Camera and Repair unfold. The polygons blend axis by axis on the same track.
4 collapsed lines
import { draw, hold, sequence, track, valueTo } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { RadarChart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const axes = ["Battery", "Screen", "Weight", "Speed", "Price"];const nextAxes = ["Battery", "Camera", "Screen", "Speed", "Repair"];const ratings = [ { phone: "Aster", v: [8, 7, 6, 9, 4] }, { phone: "Birch", v: [6, 9, 8, 6, 7] },];const nextRatings = [ { phone: "Aster", v: [7, 9, 8, 9, 3] }, { phone: "Birch", v: [9, 6, 9, 7, 8] },];
export default function RadarAxes() { const { play, signal } = usePlayer(); const progress = track(0); const blend = track(0);
onSettled(() => { void (async () => { await play(draw(progress, { duration: 1.5 })); while (!signal.aborted) { await play( sequence( hold(1), // Staged transitions ease each stage themselves: drive them linearly. valueTo(blend, 1, { duration: 1.8, easing: "linear" }), hold(1.2), valueTo(blend, 0, { duration: 1.8, easing: "linear" }), ), ); } })(); });
return ( <Stage units={10}> <RadarChart data={ratings} to={nextRatings} blend={blend} axisValues="v" key="phone" axisLabels={axes} toAxisLabels={nextAxes} maxValue={10} radius={2} progress={progress} /> </Stage> );}Heatmaps and contours
Section titled “Heatmaps and contours”Imshow paints a matrix; Pcolormesh the same on a non-uniform grid; Contour draws iso-lines and ContourF filled bands; Hist2D and HexBin bin scattered points. Tripcolor, TriContour and TriContourF do the same for scattered points by triangulating them. Covering layers paint under the axes, whose numbers get a halo to stay readable.
Heatmap with contours
A grid of values colored as a heatmap, with iso-lines of the same field drawn over it.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Axes, Stage, usePlayer } from "@sophistry/solidjs";import { Contour, Imshow } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const x = Array.from({ length: 31 }, (_, i) => -3 + i * 0.2);const y = Array.from({ length: 21 }, (_, i) => -2 + i * 0.2);const z = y.map((yy) => x.map((xx) => Math.sin(xx) * Math.cos(yy * 1.5)));
export default function HeatmapContours() { const { play } = usePlayer(); const lines = track(0);
onSettled(() => { void play(draw(lines, { duration: 2 })); });
return ( <Stage units={12}> <Axes xRange={[-3.1, 3.1, 1]} yRange={[-2.1, 2.1, 1]} width={9} height={5.5} zIndex={5} // A halo keeps the numbers clear of the white contours running under them. axis={{ stroke: "white", numberHalo: true }} > <Imshow values={z} xRange={[-3.1, 3.1]} yRange={[-2.1, 2.1]} rowOrigin="lower" ramp="viridis" /> <Contour xs={x} ys={y} values={z} stroke="white" progress={lines} /> </Axes> </Stage> );}Contours from scattered samples
Readings at scattered stations, triangulated: after the frame, the faces fade in as a wave from the top-left while the contour lines draw level by level, lowest first.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, TriContour, Tripcolor } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// 90 stations on a sunflower spiral (no grid), each reading a smooth field.const stations = Array.from({ length: 90 }, (_, i) => { const r = Math.sqrt((i + 0.5) / 90); const x = 3 * r * Math.cos(i * 2.4); const y = 2 * r * Math.sin(i * 2.4); return { x, y, temp: Math.sin(x * 1.2) * Math.cos(y) + 0.3 * x };});
export default function TriangulatedField() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 3 })); });
return ( <Stage units={12}> <Chart width={7.5} height={5} progress={progress} axis={{ position: "edge" }} > <Tripcolor data={stations} x="x" y="y" value="temp" ramp="viridis" stroke="white" strokeWidth={0.008} /> <TriContour data={stations} x="x" y="y" value="temp" levels={6} stroke="white" /> </Chart> </Stage> );}Heatmap is the categorical kind: a <Chart> with <Cells>, each cell’s value written in a color that reads on it. cluster orders rows and columns by similarity and draws their dendrograms.
Annotated heatmap
Categorical rows and columns, a colormap, and each value written in a colour that reads on its cell.
2 collapsed lines
import { Stage } from "@sophistry/solidjs";import { Heatmap } from "@sophistry/solidjs/charts";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];const hours = ["8am", "12pm", "4pm", "8pm"];const visits = days.flatMap((day, i) => hours.map((hour, j) => ({ day, hour, n: Math.round( 20 + 60 * Math.sin((i + 1) * 0.7 + j) ** 2 + (i > 4 ? 25 : 0), ), })),);
export default function HeatmapAnnotated() { return ( <Stage units={12}> <Heatmap data={visits} x="day" y="hour" value="n" ramp="viridis" width={9} height={4} title="Visits per hour" tooltip /> </Stage> );}Clustered heatmap
Hours of use per app and weekday, clustered both ways by average linkage: similar apps and similar days move next to each other, and each dendrogram replays its merges, closest first, as the cells fade in.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Heatmap } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];// Three kinds of app — work, social, games — listed out of order.const apps = [ { app: "Mail", kind: 0 }, { app: "Chat", kind: 1 }, { app: "Chess", kind: 2 }, { app: "Docs", kind: 0 }, { app: "Photos", kind: 1 }, { app: "Puzzles", kind: 2 }, { app: "Calendar", kind: 0 }, { app: "Forum", kind: 1 },];const weekday = [3, 1.2, 0.6];const weekend = [0.5, 2.5, 2.8];const usage = apps.flatMap(({ app, kind }, i) => days.map((day, j) => { const base = j >= 5 ? weekend[kind] : weekday[kind]; const wobble = 0.4 * Math.sin((i + 1) * (j + 2) * 2.3); return { app, day, hours: Math.max(0, base + wobble) }; }),);
export default function ClusteredHeatmap() { const { play } = usePlayer(); const progress = track(0); onSettled(() => { void play(draw(progress, { duration: 3 })); });
return ( <Stage units={12}> <Heatmap data={usage} x="day" y="app" value="hours" cluster labels={false} ramp="viridis" colorbar colorbarLabel="hours" width={6.4} height={3.8} center={{ x: 0.4, y: -0.3 }} dendrogramSize={0.9} progress={progress} tooltip /> </Stage> );}rampScale ("log", "symlog", "sqrt") and rampMidpoint change how values map to colors, and <Chart colorbar> follows.
Log and diverging colour norms
A field spanning four decades on a log norm, and temperature anomalies on a diverging norm centred on zero, each with a colour bar that follows its norm.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Heatmap, Imshow } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// A peak over a floor: 1 at the edges to 10,000 at the centre.const n = 24;const field = Array.from({ length: n }, (_, row) => Array.from({ length: n }, (_, col) => { const dx = (col - n / 2) / (n / 4); const dy = (row - n / 2) / (n / 4); return 10 ** (4 * Math.exp(-(dx * dx + dy * dy))); }),);
// Monthly anomalies (°C) that run warmer than they run cold.const months = ["Jan", "Mar", "May", "Jul", "Sep", "Nov"];const years = ["2020", "2021", "2022", "2023", "2024"];const anomalies = years.flatMap((year, i) => months.map((month, j) => ({ year, month, anomaly: Math.round((0.6 * i - 0.6 + 1.1 * Math.sin(i * 1.7 + j * 1.8)) * 10) / 10, })),);
export default function ColorNorms() { const { play } = usePlayer(); const progress = track(0); onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={14}> <Chart width={3.6} height={3.6} center={{ x: -3.6, y: 0 }} xRange={[0, n]} yRange={[0, n]} title={'rampScale="log"'} colorbar progress={progress} > <Imshow values={field} xRange={[0, n]} yRange={[0, n]} ramp="magma" rampScale="log" /> </Chart> <Heatmap data={anomalies} x="month" y="year" value="anomaly" labels={false} ramp="coolwarm" rampMidpoint={0} colorbar colorbarLabel="°C" title="rampMidpoint={0}" width={4.4} height={2.4} center={{ x: 3, y: -0.4 }} progress={progress} /> </Stage> );}Waterfalls, funnels and candlesticks
Section titled “Waterfalls, funnels and candlesticks”Waterfall floats each change from the running total and stands total bars on zero. Funnel stacks a process’s stages top-down with the loss between them shaded. Candlestick is a layer for price data: wicks low to high, bodies open to close.
Waterfall
How a starting figure became a final one: each change grows from where the last left off.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Waterfall } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const quarter = [ { name: "Q1 start", change: 120 }, { name: "Sales", change: 64 }, { name: "Services", change: 22 }, { name: "Refunds", change: -18 }, { name: "Salaries", change: -71 }, { name: "Rent", change: -24 }, { name: "Q1 end", change: 0, total: true },];
export default function WaterfallSteps() { const { play } = usePlayer(); const shown = track(0);
onSettled(() => { void play(draw(shown, { duration: 3.5 })); });
return ( <Stage units={13}> <Waterfall data={quarter} value="change" label="name" total={(d) => d.total === true} width={10} height={4.5} progress={shown} tooltip /> </Stage> );}Funnel
Stages of a process, top-down: each widens out from the centre, the loss between them shaded.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Funnel } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const signups = [ { step: "Visited", n: 12000 }, { step: "Signed up", n: 4800 }, { step: "Activated", n: 2600 }, { step: "Subscribed", n: 900 },];
export default function FunnelStages() { const { play } = usePlayer(); const shown = track(0);
onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Funnel data={signups} value="n" label="step" width={7} height={4.5} center={{ x: 0.8, y: 0 }} progress={shown} tooltip /> </Stage> );}Candlesticks
Prices on a time axis (inferred from Dates): each wick draws low to high, then the body grows from the open to the close.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Candlestick, Chart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// A deterministic random walk, one candle per day.const days = Array.from({ length: 20 }, (_, i) => i).reduce< { t: Date; o: number; h: number; l: number; c: number }[]>((list, i) => { const open = list.at(-1)?.c ?? 100; const close = open + Math.sin(i * 1.7) * 3 + Math.cos(i * 0.6) * 1.5; const high = Math.max(open, close) + 1 + Math.abs(Math.sin(i * 2.3)) * 2; const low = Math.min(open, close) - 1 - Math.abs(Math.cos(i * 1.1)) * 2; list.push({ t: new Date(Date.UTC(2026, 2, 2 + i)), o: open, h: high, l: low, c: close, }); return list;}, []);
export default function CandlestickPrices() { const { play } = usePlayer(); const shown = track(0);
onSettled(() => { void play(draw(shown, { duration: 3 })); });
return ( <Stage units={13}> <Chart width={10} height={4.5} grid="y" progress={shown}> <Candlestick data={days} x="t" open="o" high="h" low="l" close="c" stagger={0.7} tooltip /> </Chart> </Stage> );}Hierarchies
Section titled “Hierarchies”Treemap, Icicle, Sunburst and CirclePack take one root object as data, walk it through children, and size each leaf by value. Tree draws the same data as nodes and links (layout="cluster" for a dendrogram, orientation="radial" round a centre).
Treemap
A squarified treemap of a source tree: tiles fade in folder by folder, coloured by top-level folder.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Treemap } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Node = { name: string; lines?: number; children?: Node[] };
const repo: Node = { name: "repo", children: [ { name: "scene", children: [ { name: "shape", lines: 900 }, { name: "Label", lines: 420 }, { name: "Arc", lines: 380 }, { name: "Rect", lines: 210 }, ], }, { name: "charts", children: [ { name: "Chart", lines: 760 }, { name: "Bars", lines: 400 }, { name: "tip", lines: 230 }, ], }, { name: "anim", children: [ { name: "timeline", lines: 520 }, { name: "draw", lines: 160 }, ], }, { name: "color", lines: 450 }, ],};
export default function TreemapExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={10}> <Treemap data={repo} value="lines" label="name" width={9} height={5} paddingTop={0.32} progress={progress} tooltip /> </Stage> );}Sunburst
A sunburst of a monthly budget, revealed by one clockwise sweep from 12 o'clock.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Sunburst } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Item = { name: string; cost?: number; children?: Item[] };
const budget: Item = { name: "Budget", children: [ { name: "Home", children: [ { name: "Rent", cost: 1200 }, { name: "Power", cost: 150 }, { name: "Net", cost: 60 }, ], }, { name: "Food", children: [ { name: "Shop", cost: 420 }, { name: "Out", cost: 180 }, ], }, { name: "Travel", children: [ { name: "Train", cost: 120 }, { name: "Bike", cost: 40 }, ], }, { name: "Save", cost: 500 }, ],};
export default function SunburstExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={10}> <Sunburst data={budget} value="cost" label="name" radius={2.6} labelFontSize={0.18} progress={progress} tooltip /> </Stage> );}Dendrogram
A cluster dendrogram of a small taxonomy: elbow links grow out of the root one level at a time, leaves aligned on the right.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Tree } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Taxon = { name: string; children?: Taxon[] };
const leaves = (...names: string[]) => names.map((name) => ({ name }));const life: Taxon = { name: "Animals", children: [ { name: "Vertebrates", children: [ { name: "Mammals", children: leaves("Cat", "Whale", "Bat") }, { name: "Birds", children: leaves("Owl", "Penguin") }, { name: "Fish", children: leaves("Shark", "Salmon") }, ], }, { name: "Invertebrates", children: [ { name: "Insects", children: leaves("Ant", "Bee", "Moth") }, { name: "Molluscs", children: leaves("Octopus", "Snail") }, ], }, ],};
export default function TreeDendrogram() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={10}> <Tree data={life} label="name" layout="cluster" width={9} height={5} labelFontSize={0.2} progress={progress} tooltip /> </Stage> );}Radial dendrogram
A small family of languages as a radial cluster tree: the root in the centre, every language on the outer ring, links growing out level by level.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Tree } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Lang = { name: string; children?: Lang[] };const leaves = (...names: string[]) => names.map((name) => ({ name }));
const family: Lang = { name: "Indo-European", children: [ { name: "Germanic", children: [ { name: "West", children: leaves("English", "Dutch", "German") }, { name: "North", children: leaves("Swedish", "Danish", "Icelandic") }, ], }, { name: "Romance", children: leaves( "French", "Spanish", "Italian", "Portuguese", "Romanian", ), }, { name: "Slavic", children: [ { name: "East", children: leaves("Russian", "Ukrainian") }, { name: "West S.", children: leaves("Polish", "Czech") }, ], }, { name: "Indo-Iranian", children: leaves("Hindi", "Persian", "Bengali") }, ],};
export default function RadialTree() { const { play } = usePlayer(); const progress = track(0); onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={10}> <Tree data={family} label="name" orientation="radial" layout="cluster" width={5} height={5} labelFontSize={0.15} nodeRadius={0.04} progress={progress} tooltip /> </Stage> );}Drill-down. focus (a path of names, or { from, to, t } to animate it) zooms a node to fill the view. drill makes nodes tappable, breadcrumbs draws the path, and onFocusChange with createDrillDown() lets you own the focus as a seekable track. The node in focus and its children are tab stops; Escape zooms out.
Sunburst drill-down
Zooming into one branch of a sunburst and back out: the focus is a transition between two nodes driven by one track, so the zoom scrubs like any other animation. The chosen branch becomes the centre and its children open out round the whole turn.
4 collapsed lines
import { derive, draw, hold, sequence, track, valueTo } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Sunburst } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Item = { name: string; kb?: number; children?: Item[] };const files = (...entries: [string, number][]) => entries.map(([name, kb]) => ({ name, kb }));
const repo: Item = { name: "repo", children: [ { name: "src", children: [ { name: "charts", children: files(["bars", 40], ["pie", 22], ["tree", 30]), }, { name: "scene", children: files(["shape", 35], ["text", 18]) }, { name: "anim", kb: 26 }, ], }, { name: "docs", children: files(["guides", 30], ["api", 24]) }, { name: "tests", children: files(["unit", 28], ["e2e", 14]) }, ],};
export default function SunburstDrillDown() { const { play, signal } = usePlayer(); const progress = track(0); const zoom = track(0); const focus = derive(zoom, (t) => ({ from: [], to: ["src"], t }));
onSettled(() => { void (async () => { await play(draw(progress, { duration: 2 })); while (!signal.aborted) { await play( sequence( hold(0.8), valueTo(zoom, 1, { duration: 1.4 }), hold(1.4), valueTo(zoom, 0, { duration: 1.4 }), ), ); } })(); });
return ( <Stage units={10}> <Sunburst data={repo} value="kb" label="name" radius={2.5} labelFontSize={0.18} progress={progress} focus={focus} tooltip /> </Stage> );}Tap to drill into a treemap
Tap a tile to zoom into its folder, tap a crumb above to zoom back out; Tab and Enter do the same. The zoom is a tween of the chart's focus, so it is exactly the scrubbable drill-down transition, and under reduced motion it dissolves instead.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Treemap } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Item = { name: string; kb?: number; children?: Item[] };const files = (...entries: [string, number][]) => entries.map(([name, kb]) => ({ name, kb }));
const repo: Item = { name: "repo", children: [ { name: "src", children: [ { name: "charts", children: files(["bars", 40], ["pie", 22], ["tree", 30]), }, { name: "scene", children: files(["shape", 35], ["text", 18]) }, { name: "anim", kb: 26 }, ], }, { name: "docs", children: files(["guides", 30], ["api", 24]) }, { name: "tests", children: files(["unit", 28], ["e2e", 14]) }, ],};
export default function TreemapDrillDown() { const player = usePlayer(); const progress = track(0); onSettled(() => { void player.play(draw(progress, { duration: 1.5 })); });
return ( <Stage units={10}> <Treemap data={repo} value="kb" label="name" width={8} height={3.9} center={{ x: 0, y: -0.4 }} paddingTop={0.3} labelFontSize={0.2} progress={progress} drill breadcrumbs tooltip /> </Stage> );}Zoomable circle packing
Tap a circle to zoom into it and the background to zoom out, along d3's smooth zoom path. The chart is controlled: createDrillDown holds the focus and tweens it, and the same focus drives the breadcrumb trail, so both scrub together.
3 collapsed lines
import { createDrillDown } from "@sophistry/charts";import { Stage, useScene } from "@sophistry/solidjs";import { Breadcrumbs, CirclePack } from "@sophistry/solidjs/charts";
type Item = { name: string; n?: number; children?: Item[] };const leaves = (...entries: [string, number][]) => entries.map(([name, n]) => ({ name, n }));
const life: Item = { name: "life", children: [ { name: "animals", children: [ { name: "birds", children: leaves(["owl", 4], ["wren", 2], ["heron", 3]), }, { name: "fish", children: leaves(["cod", 3], ["eel", 2]) }, { name: "insects", children: leaves(["bee", 5], ["ant", 6], ["moth", 2]), }, ], }, { name: "plants", children: [ { name: "trees", children: leaves(["oak", 4], ["fir", 3]) }, { name: "ferns", n: 3 }, ], }, { name: "fungi", children: leaves(["yeast", 2], ["mould", 3]) }, ],};
/** Inside the stage, so the zoom runs on its clock and reduced-motion policy. */function Zoomable() { const scene = useScene(); const zoom = createDrillDown({ duration: 0.9, clock: scene.clock, reducedMotion: scene.reducedMotion, }); return ( <> <Breadcrumbs path={zoom.focus} root="life" y={2.45} align="center" onSelect={zoom.zoomTo} /> <CirclePack data={life} value="n" label="name" radius={2.15} center={{ x: 0, y: -0.25 }} labelFontSize={0.17} focus={zoom.focus} onFocusChange={zoom.zoomTo} tooltip /> </> );}
export default function ZoomableCirclePack() { return ( <Stage units={10}> <Zoomable /> </Stage> );}Transitions. Trees transition with to and blend, matched by name path. Keep the order stable for clean frames: sort={false}, and on a treemap tile="resquarify", which lays to out in data’s rows.
Treemap data transition
One budget, two years. Tiles are matched by their path of names: the team that was cut fades out, the others resize into place, the new team fades in. One blend track drives it, so it scrubs. Data order and an order-keeping tile keep every frame a clean tiling.
4 collapsed lines
import { draw, hold, sequence, track, valueTo } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Treemap } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Item = { name: string; k?: number; children?: Item[] };const teams = (...entries: [string, number][]) => entries.map(([name, k]) => ({ name, k }));
const lastYear: Item = { name: "budget", children: [ { name: "Product", children: teams(["Web", 30], ["Mobile", 22], ["Labs", 12]), }, { name: "Sales", children: teams(["EMEA", 18], ["Americas", 26]) }, { name: "Ops", children: teams(["Infra", 16], ["Support", 10]) }, ],};const thisYear: Item = { name: "budget", children: [ { name: "Product", children: teams(["Web", 26], ["Mobile", 30], ["AI", 20]), }, { name: "Sales", children: teams(["EMEA", 22], ["Americas", 24]) }, { name: "Ops", children: teams(["Infra", 12], ["Support", 10]) }, ],};
export default function TreemapTransition() { const { play, signal } = usePlayer(); const progress = track(0); const blend = track(0);
onSettled(() => { void (async () => { await play(draw(progress, { duration: 1.5 })); while (!signal.aborted) { await play( sequence( hold(1), valueTo(blend, 1, { duration: 1.8, easing: "linear" }), hold(1.2), valueTo(blend, 0, { duration: 1.8, easing: "linear" }), ), ); } })(); });
return ( <Stage units={10}> <Treemap data={lastYear} to={thisYear} blend={blend} value="k" label="name" tile="sliceDice" sort={false} width={8} height={4.2} paddingTop={0.3} progress={progress} tooltip /> </Stage> );}Tree data transition
A reorganisation as a node-link tree. Nodes are matched by their path of names: the team that was wound up draws back into its parent, the rest slide to their new places with their links following, then the new teams grow out of theirs. One blend track drives it, so it scrubs.
4 collapsed lines
import { draw, hold, sequence, track, valueTo } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Tree } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
type Unit = { name: string; children?: Unit[] };const teams = (...names: string[]) => names.map((name) => ({ name }));
const before: Unit = { name: "CTO", children: [ { name: "Platform", children: teams("Infra", "Data", "Security") }, { name: "Product", children: teams("Web", "Mobile") }, { name: "Labs", children: teams("Research") }, ],};const after: Unit = { name: "CTO", children: [ { name: "Platform", children: teams("Infra", "Data") }, { name: "Product", children: teams("Web", "Mobile", "Growth") }, { name: "Trust", children: teams("Security", "Privacy") }, ],};
export default function TreeTransition() { const { play, signal } = usePlayer(); const progress = track(0); const blend = track(0);
onSettled(() => { void (async () => { await play(draw(progress, { duration: 1.5 })); while (!signal.aborted) { await play( sequence( hold(1), // Staged transitions ease each stage themselves: drive them linearly. valueTo(blend, 1, { duration: 1.8, easing: "linear" }), hold(1.2), valueTo(blend, 0, { duration: 1.8, easing: "linear" }), ), ); } })(); });
return ( <Stage units={10}> <Tree data={before} to={after} blend={blend} label="name" width={8} height={4.2} progress={progress} tooltip /> </Stage> );}Sankey takes links (source, target, value) and works out the nodes. Chord lays the same records round a circle; directed gives every flow its own ribbon and arrows arrowheads. ParallelCoordinates draws each datum as a line across one axis per measure.
Sankey diagram
Energy flowing from sources to uses: nodes appear column by column, then the flows draw left to right.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Sankey } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const flows = [ { from: "Solar", to: "Electricity", twh: 3 }, { from: "Wind", to: "Electricity", twh: 5 }, { from: "Gas", to: "Electricity", twh: 4 }, { from: "Gas", to: "Heat", twh: 3 }, { from: "Electricity", to: "Homes", twh: 5 }, { from: "Electricity", to: "Industry", twh: 6 }, { from: "Electricity", to: "Losses", twh: 1 }, { from: "Heat", to: "Homes", twh: 3 },];
export default function SankeyExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 3 })); });
return ( <Stage units={10}> <Sankey data={flows} source="from" target="to" value="twh" width={7} height={4} progress={progress} tooltip /> </Stage> );}Chord diagram
Migration between four regions: the ring sweeps round like a pie, then each chord fades in, as wide at each end as the flow leaving it.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chord } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const moves = [ { from: "North", to: "South", people: 12 }, { from: "South", to: "North", people: 7 }, { from: "North", to: "East", people: 5 }, { from: "East", to: "West", people: 9 }, { from: "West", to: "East", people: 4 }, { from: "West", to: "South", people: 6 }, { from: "South", to: "East", people: 3 }, { from: "East", to: "North", people: 4 },];
export default function ChordDiagram() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 3 })); });
return ( <Stage units={10}> <Chord data={moves} source="from" target="to" value="people" radius={2.2} progress={progress} tooltip /> </Stage> );}Parallel coordinates
Four car measurements side by side: each car is a line across the axes, drawn left to right once the axes are in.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { ParallelCoordinates } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const cars = [ { mpg: 18, hp: 150, kg: 1590, s: 11.5 }, { mpg: 15, hp: 198, kg: 1950, s: 10.0 }, { mpg: 24, hp: 95, kg: 1160, s: 15.0 }, { mpg: 27, hp: 88, kg: 1020, s: 14.5 }, { mpg: 31, hp: 67, kg: 900, s: 19.0 }, { mpg: 36, hp: 58, kg: 800, s: 18.5 }, { mpg: 21, hp: 110, kg: 1300, s: 14.0 }, { mpg: 13, hp: 215, kg: 2100, s: 9.5 },];
export default function ParallelCoordinatesExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={10}> <ParallelCoordinates data={cars} axes={[ { value: "mpg", label: "mpg" }, { value: "hp", label: "horsepower" }, { value: "kg", label: "weight (kg)" }, { value: "s", label: "0–60 (s)" }, ]} color={(d) => (d.mpg >= 25 ? "#3fb68b" : "#e07a5f")} width={7} height={3.6} center={{ x: 0.3, y: -0.3 }} progress={progress} tooltip /> </Stage> );}Gauges, bullets, waffles, mosaics and radial bars
Section titled “Gauges, bullets, waffles, mosaics and radial bars”Gauge shows one value on an arc with threshold bands. Bullet is a bar over qualitative ranges with a target line. Waffle shows shares as unit cells that always add up. Mosaic draws a two-way table where every tile’s area is its value. RadialBarChart draws one ring per datum.
KPI gauge and radial bars
A gauge with threshold bands and a needle, beside activity rings. Each draws its track first, then sweeps clockwise while the readout counts up.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Gauge, RadialBarChart } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const rings = [ { goal: "Move", pct: 82 }, { goal: "Exercise", pct: 64 }, { goal: "Stand", pct: 45 },];
export default function GaugeExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={12}> <Gauge value={72.4} unit="%" label="CPU load" bands={[ { to: 60, color: "#83c167" }, { to: 85, color: "#f0ac5f" }, { to: 100, color: "#fc6255" }, ]} needle center={{ x: -2.8, y: 0 }} radius={2.2} progress={progress} tooltip /> <RadialBarChart data={rings} value="pct" label="goal" maxValue={100} center={{ x: 2.8, y: 0 }} radius={2.2} progress={progress} tooltip /> </Stage> );}Bullet chart
Stephen Few's bullet graph: four KPIs against their targets over poor / fair / good bands, each on its own scale. The bands fade in first, then each bar grows from zero and its target marker draws in.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Bullet } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const kpis = [ { name: "Revenue ($k)", actual: 270, goal: 250, bands: [150, 225, 300] }, { name: "Profit (%)", actual: 22.5, goal: 27, bands: [20, 25, 30] }, { name: "Order size ($)", actual: 320, goal: 550, bands: [350, 500, 600] }, { name: "Satisfaction", actual: 4.3, goal: 4.5, bands: [3.5, 4.25, 5] },];
export default function BulletChart() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={12}> <Bullet data={kpis} value="actual" target="goal" ranges="bands" label="name" width={10.5} height={5} progress={progress} tooltip /> </Stage> );}Waffle chart
A 10 × 10 waffle where each cell is one percent, filling from the bottom-left like a container. Counts use largest-remainder rounding, so they always add up to 100.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Waffle } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const commute = [ { mode: "Bike", share: 41.6 }, { mode: "Bus", share: 30.1 }, { mode: "Car", share: 18.9 }, { mode: "Walk", share: 9.4 },];
export default function WaffleExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={10}> <Waffle data={commute} value="share" label="mode" width={4} height={4} center={{ x: 0, y: 0.5 }} legend progress={progress} tooltip /> </Stage> );}Stacked areas
Section titled “Stacked areas”StackPlot takes wide rows with one y channel per band (series names them), or long rows with one y and a series channel. offset="wiggle" with order="insideOut" makes a streamgraph.
Stacked areas
Wide-format rows (one object per x) become stacked bands: y takes one channel per band, mixing keys and functions, and series names them, so the bands take the chart's colours and legend.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, StackPlot } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const rows = Array.from({ length: 13 }, (_, month) => ({ month, web: 3 + Math.sin(month / 2) * 1.2, mobile: 2 + month * 0.25, api: 1.5 + Math.cos(month / 3) * 0.6,}));
export default function StackedAreas() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={12}> <Chart xRange={[0, 12, 2]} yRange={[0, 10, 2]} width={9} height={4.6} // The top legend sits above height: leave it room. center={{ x: 0, y: -0.3 }} xLabel="month" legend="top" progress={progress} > <StackPlot data={rows} x="month" y={["web", "mobile", (row) => row.api]} series={["web", "mobile", "api"]} /> </Chart> </Stage> );}Streamgraph
StackPlot with offset="wiggle" and order="insideOut": the layers float around a centre line chosen to keep them as level as possible, and the whole stream grows out of it. The week axis sits at the bottom edge (xAxis position) rather than through the stream, and series names the bands for the legend.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, StackPlot } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// Five smooth bumps peaking at different weeks.const bump = (week: number, peak: number, width: number, height: number) => height * Math.exp(-(((week - peak) / width) ** 2)) + 0.3;const genres = ["jazz", "folk", "rock", "soul", "funk"] as const;const rows = Array.from({ length: 41 }, (_, week) => ({ week, jazz: bump(week, 8, 6, 4), folk: bump(week, 16, 7, 3), rock: bump(week, 22, 5, 5), soul: bump(week, 28, 8, 3), funk: bump(week, 34, 5, 4),}));
export default function Streamgraph() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart // The legend's room comes out of width (autosize="fit"). width={10.5} height={4.5} // A stream floats around zero, mid-chart: draw the week axis // along the bottom edge instead of through the stream. Its // y values are offsets, not quantities, so that axis is hidden. xAxis={{ position: "bottom" }} yAxis={{ visible: false }} xLabel="week" grid="x" progress={shown} > <StackPlot data={rows} x="week" y={genres} series={genres} offset="wiggle" order="insideOut" /> </Chart> </Stage> );}3D charts
Section titled “3D charts”The 3D charts live in their own entry, @sophistry/charts/3d (components in @sophistry/solidjs/charts/3d), so the 2D charts never need @sophistry/3d. They follow the same data-and-channels conventions, render under a camera3D (<Camera3D> from @sophistry/solidjs/3d), and take the props of the primitive they draw (shaded, stroke, opacity, handlers, …). In them z is a data channel; zIndex is still the paint order.
| Component | Needs | Notable options |
|---|---|---|
BarChart3D |
x, y, z, height |
width, depth (default 1), color, colors |
Scatter3D |
x, y, z |
radius, color |
Stem3D |
x, y, z |
baseline, markerRadius, color |
Quiver3D |
x, y, z, u, v, w |
scale, color |
SurfaceGrid3D |
xs, ys, zs (grids) |
the mesh’s paint props |
TriSurface3D |
x, y, z |
the mesh’s paint props |
Voxels3D |
values (a 3D grid of booleans) |
the mesh’s paint props |
Wireframe3D |
xs, ys, zs (grids) |
the line props |
Charts of many marks (BarChart3D, Quiver3D, Scatter3D, Stem3D, Wireframe3D) draw one 3D primitive per datum or segment; surfaces (SurfaceGrid3D, TriSurface3D, Voxels3D) are one mesh each. A camera move only re-projects them. See 3D.
3D bar chart
A 3 by 3 grid of bars whose heights come from one array; each box is anchored at its corner and rises along y.
4 collapsed lines
import { track } from "@sophistry/core";import { Stage } from "@sophistry/solidjs";import { Axes3D, Camera3D, useOrbitControls3D } from "@sophistry/solidjs/3d";import { BarChart3D } from "@sophistry/solidjs/charts/3d";
const HEIGHTS = [1, 2, 1.5, 2.5, 3, 2, 1, 1.8, 0.8];const TARGET = { x: 1.5, y: 1, z: 1.5 };
function Bars() { const eye = track({ x: 6, y: 5, z: 8 }); // Orbit around the camera's target, the middle of the grid. useOrbitControls3D({ eye, target: TARGET });
return ( <Camera3D eye={eye} target={TARGET}> <Axes3D length={4} /> <BarChart3D data={HEIGHTS} x={(_, i) => (i % 3) * 1.3} y={0} z={(_, i) => Math.floor(i / 3) * 1.3} height={(height) => height} /> </Camera3D> );}
export default function BarChart3DExample() { return ( <Stage units={10}> <Bars /> </Stage> );}Surface plot
A rippling surface y = f(x, z) sampled from a function of two parameters; drag to orbit around it.
8 collapsed lines
import { track } from "@sophistry/core";import { Stage } from "@sophistry/solidjs";import { Axes3D, Camera3D, SurfacePlot3D, useOrbitControls3D,} from "@sophistry/solidjs/3d";
function Ripple() { const eye = track({ x: 5, y: 4, z: 7 }); useOrbitControls3D({ eye });
return ( <Camera3D eye={eye}> <Axes3D length={3} /> <SurfacePlot3D resolution={32} function={(u, v) => { const x = (u - 0.5) * 5; const z = (v - 0.5) * 5; return { x, y: Math.cos(1.6 * Math.hypot(x, z)) * 0.8, z }; }} /> </Camera3D> );}
export default function SurfacePlot3DExample() { return ( <Stage units={10}> <Ripple /> </Stage> );}Next steps
Section titled “Next steps”- Charts: the model behind every chart here.
- Chart animation: reveals and data transitions.
- Plotting gallery: more examples, grouped by kind of chart.