⚠ 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
Hierarchies, networks and flows
Nested and connected data: hierarchy marks that take a tree, transitions that match nodes by their path of names, network layouts, and flows between groups. Start with Treemap and Sunburst; the drill-down versions are in Cameras, zoom and drill-down.
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> );}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> );}Treemap transition that keeps its rows
The values reorder, so a fresh squarify would re-row the tiles and slide them across each other. tile="resquarify" lays the new values out in the old rows instead: every tile keeps its neighbours and every frame is a clean tiling, at the cost of the end not being the plain squarified layout.
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 shares = (...entries: [string, number][]): Item => ({ name: "market", children: entries.map(([name, k]) => ({ name, k })),});
const before = shares( ["Alder", 30], ["Birch", 24], ["Cedar", 16], ["Dogwood", 12], ["Elm", 8], ["Fir", 6], ["Gum", 4],);const after = shares( ["Alder", 8], ["Birch", 12], ["Cedar", 14], ["Dogwood", 16], ["Elm", 18], ["Fir", 20], ["Gum", 12],);
export default function TreemapResquarify() { 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={before} to={after} blend={blend} tile="resquarify" value="k" label="name" width={8} height={4.6} progress={progress} tooltip /> </Stage> );}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> );}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> );}Network layouts
One set of vertices and edges placed three ways by changing only the layout prop.
3 collapsed lines
import { draw, track } from "@sophistry/core";import { NetworkGraph, Stage, Text, usePlayer } from "@sophistry/solidjs";import { onSettled } from "solid-js";
const vertices = [1, 2, 3, 4, 5, 6];const edges: [number, number][] = [ [1, 2], [1, 3], [2, 4], [2, 5], [3, 6],];
export default function NetworkLayouts() { const { play } = usePlayer(); const drawn = track(0);
onSettled(() => { void play(draw(drawn, { duration: 2 })); });
return ( <Stage units={14}> <NetworkGraph vertices={vertices} edges={edges} layout="circular" center={{ x: -4.6, y: 0 }} progress={drawn} /> <NetworkGraph vertices={vertices} edges={edges} layout="tree" layoutOptions={{ root: 1 }} layoutScale={{ width: 3.5, height: 3.5 }} center={{ x: 0, y: 0 }} progress={drawn} /> <NetworkGraph vertices={vertices} edges={edges} layout="grid" layoutScale={{ width: 3.5, height: 2 }} center={{ x: 4.6, y: 0 }} progress={drawn} /> <Text text="circular" x={-4.6} y={-3.2} /> <Text text="tree" x={0} y={-3.2} /> <Text text="grid" x={4.6} y={-3.2} /> </Stage> );}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> );}Directed chord diagram
Who emails whom: one chord per direction, each as wide at both ends as its flow, ending in an arrowhead on the team it reaches. A team that only receives still gets its arc.
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 mail = [ { from: "Sales", to: "Support", n: 14 }, { from: "Support", to: "Sales", n: 6 }, { from: "Sales", to: "Legal", n: 5 }, { from: "Product", to: "Support", n: 9 }, { from: "Product", to: "Sales", n: 7 }, { from: "Support", to: "Product", n: 11 }, { from: "Product", to: "Legal", n: 3 },];
export default function DirectedChord() { const { play } = usePlayer(); const progress = track(0); onSettled(() => { void play(draw(progress, { duration: 3 })); });
return ( <Stage units={10}> <Chord data={mail} source="from" target="to" value="n" directed arrows radius={2.2} padAngle={0.06} progress={progress} tooltip /> </Stage> );}