Anatomy of a figure
The template every figure page follows
Every figure on this site is a d3 drawing with a numbered caption. The drawing below is real — it shows the citation records of release 2606 by parser outcome — and this page is also the contract: a new figure lane copies this file and its script, swaps in its own data, and ships. Hover or focus a bar to see the shared fact box.
Source: release 2606 parser outcomes, as published on the dataset page. This template inlines the same counts; real figures fetch a receipted JSON payload instead.
The conventions
-
One page, one script, one registry row. A figure
lives at
src/pages/figures/<slug>.astrowith its drawing code insrc/scripts/figures/<slug>.ts(pulled in with<script src>, so it ships as an external file andscript-src 'self'holds) and one entry insrc/lib/figure-registry.ts. -
Data is a bounded, receipted JSON payload at
/data/figures/<slug>.json(at most 3 MB), loaded throughloadFigureData(). This template inlines a constant only because it documents the site itself. -
No inline styles, ever. The CSP forbids
<style>elements, style attributes, andel.style.*. Colors come from kit classes — a.fill-hbar inside an.h-cyangroup on aclass="dg"svg — or from presentation attributes carrying hexes read viareadTokens(). Geometry goes through.attr();var()never resolves inside a presentation attribute. -
Axis microtype is Monaspace Neon at 0.72 rem in
--ink-2(.fig-axis); gridlines are hairlines in--rule. Exact counts in captions and fact boxes use thin-space grouping (formatExact()); axis ticks useformatSi(). -
Marks that carry detail are keyboard-reachable:
tabindex="0"and anaria-labelnaming the value. The shared fact box opens on hover and on focus; there are no hover tooltips as the only carrier of a number. -
The render is width-aware: the whole drawing
lives in a
render(width)driven byonFigureWidthChange(), and below 560 px it re-composes — margins, tick sets, label forms — instead of stretching one viewBox across sizes. -
Motion is a garnish, never a gate. CSS motion
lives under
.dg-runand dies underprefers-reduced-motion; scripted motion asksrespectMotion()first. - The caption states its source and its denominator. Every number traces to a receipt or a computed artifact, and the caption says what population it describes.
The kit lives in src/styles/figure-kit.css and
src/scripts/figures/kit.ts: page tokens, the
--dg-* diagram palette shared with doering.ai, the fact
box, formatters, and the token reader. What the kit lacks, a lane
adds there — not as a private copy.