Analytic figures
The analytic figure family - waterfall, bullet, box plot, fan chart and the shared heatmap painter used by the order book and the candle screener.
This page covers the analytic figures: painters that plot values on a domain axis instead of a clock.
Every painter reads the same AnalyticPaintInput, takes its colors from the theme and the look pack,
and degrades to flat fills when gradients are unavailable.
Every figure is drawn by the public core painters (`paintWaterfall`, `paintBullet`, `paintBoxPlot`, `paintFanChart`, `paintHeatmapGrid`) inside a plotted frame: value grid and axis captions come from the host, the waterfall bridge, the step values and the fan band legend are host chrome around the painter, and colours and the reading font come from the theme and the look pack only.
Figure catalogue
| Figure | Painter | Data | Notes |
|---|---|---|---|
| Waterfall | paintWaterfall | Steps { label, value, kind } | start grows from zero, delta stacks on the running base, total spans the accumulated value; waterfallSpans holds the base arithmetic |
| Bullet | paintBullet | { value, target?, ranges } | Qualitative bands behind a solid value marker and a dashed target tick; the scale clamps out-of-range targets |
| Box plot | quantiles, paintBoxPlot | A sample of numbers | Quartiles by linear interpolation (R type 7), whiskers at 1.5 IQR, outliers as marks |
| Fan chart | paintFanChart | Median plus band pairs | Bands are drawn widest first so the narrowest reads on top; the median reuses paintAnalyticCurve |
| Heatmap | paintHeatmapGrid | HeatmapGridLike | One painter for every heatmap in the library: depth landscape, monthly returns and the candle screener |
Waterfall
Pass one step per row and mark its kind: start opens the bridge, delta moves it, total closes it
at the accumulated value.
import { DARK_THEME, NumericAxis, paintWaterfall, waterfallSpans } from '@unifin/chart-core';
const steps = [
{ label: 'Revenue', value: 820, kind: 'start' as const },
{ label: 'Costs', value: -310, kind: 'delta' as const },
{ label: 'Net', value: 0, kind: 'total' as const },
];
const input = {
xAxis: new NumericAxis({ min: 0, max: steps.length, width: 640 }),
yMin: 0,
yMax: 900,
plotWidth: 640,
height: 320,
theme: DARK_THEME,
};
paintWaterfall(ctx, steps, input); // -> painted columns
waterfallSpans(steps); // -> running bases, no canvas neededBullet
ranges are the qualitative bands (bad, target, good), value is the solid marker and target the
dashed tick. Targets outside the scale are clamped instead of widening it.
paintBullet(
ctx,
{ value: 74, target: 80, ranges: [40, 70, 100] },
{ xAxis, yMin: 0, yMax: 100, plotWidth: 320, height: 120, theme: DARK_THEME },
);The bands are painted top-down with a rising alpha, then the value marker (solid) and the target
tick (dashed). bulletRanges sorts and filters the boundaries, bulletScale fixes the upper bound.
Box plot
quantiles is pure, so the numbers can be asserted without a canvas: quartiles use linear
interpolation, whiskers stop at the last value inside 1.5 x IQR, and anything further out is
reported as an outlier. A sample with fewer than two finite values returns null instead of a
degenerate box.
const box = quantiles(samples);
if (box !== null) {
paintBoxPlot(ctx, [box], { xAxis, yMin: box.min, yMax: box.max, plotWidth: 160, height: 320, theme: DARK_THEME });
}Fan chart
The fan chart is a composition: each band is a paintAnalyticBand call and the median is
paintAnalyticCurve. Both clip horizontally, so a long scenario cone stays cheap, and the bands
accept any pair of AnalyticPoint lists - a Monte Carlo cone feeds them directly.
paintFanChart(
ctx,
median, // AnalyticPoint[]
[
{ low: p10, high: p90 },
{ low: p25, high: p75 },
],
{ xAxis, yMin, yMax, plotWidth: 720, height: 360, theme: DARK_THEME },
);Bands are drawn widest first and the alpha steps up towards the median (FAN_BAND_ALPHA plus
FAN_BAND_ALPHA_STEP per band).
Heatmaps
heatmapColor is the single place where a cell color is decided: the tone picks the palette
(accent, up, down or the signed diverging) and the intensity picks the alpha from a quantised
cache. bookGrid adapts the order book landscape and monthlyGrid (portfolio kit) adapts the
returns grid, so a new heatmap is data plus a tone - never a new painter.
import { candleHeatmapGrid, DARK_THEME, paintHeatmapGrid } from '@unifin/chart-core';
const grid = candleHeatmapGrid(cells); // { symbol, period, change }
paintHeatmapGrid(ctx, { grid, tone: 'diverging', theme: DARK_THEME, width: 640, height: 360 });See also
- Analytics kits - domain packages that feed these figures.
- Pro terminal panels - the same painters inside the Pro panels.
- Order book chart - the heatmap painter in a live panel.
- API overview - painter signatures and inputs.
Pro edition
What the Pro entry point of Unifin Charts adds - the live look engine, the workspace layer, the terminal panels and the order book chart, white-label and within its 500 KB ceiling.
Terminal panels
The five Pro terminal panels - liquidity ribbon, delta candles, pace of tape, auction landscape and efficient frontier, with the models behind them.
