/docsfor

Sizing

How a figure takes its width, height, and type size, and how to fit one to a fluid box.

Every figure is drawn in CSS pixels. The root svg carries width, height, and a viewBox of the same size, so one unit inside the figure is one pixel on the page. Margins, hairlines, hit areas, and type are pixel measures, and the chart's 11px tick labels are the same 11px as your captions.

PropWhat it setsDefault
widthRendered width in CSS pixels640
heightRendered height in CSS pixelswidth / aspect
aspectWidth over height when height is not givenPer form, most are 5 / 3
fontSizeType size in CSS pixels; every text role follows it11
p50 latency by region38msedge64msus-east71msus-west92mseu-west148msap-south173mssa-east
fig. 01 · The default: 640px wide at 11px type

A narrower host

The root style is display: block; max-width: 100%; height: auto. A host narrower than the figure shrinks it as a whole, like an image, and a wider host leaves it at its size. To keep 11px type on a narrow card, pass a smaller width instead of letting the figure shrink.

p50 latency by region38msedge64msus-east71msus-west92mseu-west148msap-south173mssa-east
fig. 02 · width={360}: the frame is laid out again for 360px, and the type stays at 11px

Type

fontSize is the one type knob. Axis and category labels print at that size, printed values step up a tenth, and a chart's own large numbers are multiples of it. The gutters that hold the type are computed from it too, so larger type still has room.

p50 latency by region38msedge64msus-east71msus-west92mseu-west148msap-south173mssa-east
fig. 03 · fontSize={13}: every role and every gutter follows

The family is inherited through var(--dg-font, inherit). There is no per-role size prop and no font prop.

A fluid box

When the width comes from layout rather than from your code, Fit from diagrammatic/interactive measures its box and hands the width down. It renders initial (640 by default) on the server and on the first client render, then redraws at the measured width in steps of step pixels.

"use client";

import { Area } from "diagrammatic";
import { Fit } from "diagrammatic/interactive";

<Fit>{({ width }) => <Area data={signups} width={width} aspect={3} yTicks={3} />}</Fit>;
Daily signups0204045
fig. 03 · Fit measures its box and hands the width down; resize the window to watch type hold at 11px

The chart inside the callback is a client component, because the callback is. Measure once at the wrapper; the charts never measure themselves.

Text that does not fit

Nothing is drawn outside the box. A row label longer than its gutter is cut with an ellipsis, a legend that would cross the edge cuts its names, and an end value is pulled inside the frame. Widths are estimated as chars × fontSize × 0.6, because a server render cannot measure glyphs. truncate, textWidth, and charsThatFit are exported for laying out your own labels by the same rule.