Chartsv26.10.18
Pro edition

Order book chart

The Pro order book chart - ten canvas variants of a live two-sided book with gradients, themes and the look pack.

This page covers the Pro order book chart: ten canvas variants, the component surface, the look pack and the core painter behind them.

It is part of the Pro edition: the engine is the same as in Standard, the widget is not.

The order book chart turns a two-sided book into one of ten canvas views. It is a Pro feature: the painter lives in the core, the OrderbookChart component ships in @unifin/chart-react/pro, and the whole surface is presentation only - the data comes from OrderbookModel, so the same widget serves a live feed, a replay or a recorded session.

Try it live

Theme
Best bid
12949.50
Best ask
12950.50
Spread
1.00
Mid
12950.00
Imbalance
0.05
Bid / ask
20.2K / 18.1K

Rendered by `OrderbookChart` from `@unifin/chart-react/pro` - a Pro component over the public `paintOrderbookChart` of the core. The book is synthetic; every control drives the real props (variant, theme, look pack, aggregation step, book depth).

Every control drives the real props: the variant chips switch the painter, the palette and font feed the look pack, the aggregation step buckets the prices, the book depth caps the rows, and the theme button repaints through the shell tokens.

Ten variants

The ten variants share one normalised view (buildOrderbookView) and one price scale; only the body of the picture changes. The first three match the familiar terminal readings, the next two are liquidity-first views, and the S96 desk wave adds five more readings - the mirror ladder, the depth bubbles, the ridgeline, the radial sonar and the walls.

VariantWhat it drawsBest for
depthCumulative depth curves of both sides around the mid price, filled with a vertical gradientReading where the book walls are
depthHistogramPer-level columns diverging from the mid ruleComparing one level against its neighbours
ladderThe classic price ladder with depth shading, a spread band, side totals and a mini depth stripPlacing an order at a price
heatmapA price x time liquidity landscape with an intensity heat scaleWatching liquidity build and pull over time
imbalanceA pressure board - a bid/ask share gauge over diverging price rowsReading who owns the book
mirrorThe mirror ladder: cumulative staircase bars left of the bids and right of the asks around a central price column, with the spread band between the sidesTwo-sided weight at a glance, mid anchored
bubblesDepth bubbles over a faint cumulative skirt; the radius follows the level size and the three heaviest levels carry their sizeSpotting single heavy levels in a sparse book
ridgesA liquidity ridgeline: one soft ridge per level, lower rows first, the heaviest level labelledThe shape of the whole ladder as a skyline
radialA radial depth sonar: two filled lobes sweeping a half-circle per side over guide rings, with the mid and the spread at the centreA showcase reading of the two-sided weight
wallsGlowing liquidity walls: one pillar per level standing on the base line, the three heaviest labelled with their sizeWhere the walls really are

Gradient bodies degrade gracefully: a canvas without createLinearGradient keeps flat withAlpha fills, the bubbles fall back to soft squares without arc, the radial lobes to flat fills without createRadialGradient, so the widget stays legible on every backend.

Look pack and themes

The chart reads the same look pack as the price chart: the bar palette resolves bids and asks (classic, neon, sunset, ice, mono), the reading font comes from the four-font set, and every colour is derived from the active theme - no literal ever enters the painter, so a white-label shell repaints through its --ud-* tokens.

Component

import { OrderbookChart } from '@unifin/chart-react/pro';
import { OrderbookModel } from '@unifin/chart-core';

const book = new OrderbookModel();

export function Book({ snapshot, look }) {
  book.apply(snapshot);
  return (
    <OrderbookChart
      depth={book.depth(12)}
      variant="depth"
      look={look}
      step={0.5}
      levels={12}
      title="AAPL - NASDAQ"
      locale="en"
      height={360}
    />
  );
}
PropMeaning
depthTwo-sided depth, best first (OrderbookModel.depth(levels)); the only required prop
variantdepth (default), depthHistogram, ladder, heatmap, imbalance, mirror, bubbles, ridges, radial, walls
themeA ChartTheme; defaults to the dark palette
lookThe look pack - bar palette, gradient bodies and the reading font
levelsRows kept per side (book depth), default 12
stepPrice aggregation step; derived from the level gaps when omitted
heatmapA HeatmapGrid for the heatmap variant (from BookHeatmap.grid())
titleInstrument stamp of the header
localeHeader and axis language
heightFixed pixel height of the canvas host

The component exposes the book to assistive technology as a single role="img" with a label carrying the variant, spread and imbalance. It is a pure presentation surface: it never mutates the model and never places orders - use OrderbookLadder for clickable levels and order intents.

Core painter

paintOrderbookChart(ctx, input) and buildOrderbookView(input) are public in @unifin/chart-core (also on the @unifin/chart-core/render subpath), so a host that draws its own canvas can reuse the exact same geometry and palette:

import { buildOrderbookView, paintOrderbookChart, DARK_THEME } from '@unifin/chart-core';

const view = buildOrderbookView({ depth: book.depth(20), step: 0.5, levels: 20 });
paintOrderbookChart(ctx, { variant: 'imbalance', view, theme: DARK_THEME, width, height, locale: 'en' });

The book cube in 3D

The depth history behind the heatmap also reads as a cube: every snapshot becomes a column, the price axis spans the levels and the level size sets the bar height, with the active snapshot in the accent tone. Drag, the wheel and the arrow keys steer the camera; the reset button and the two angle presets restore the canonical views, and the scene pauses while the section is out of view or the tab is hidden.

Theme
yaw 0.60 · pitch 0.90 · scale 1.00
The order book cube: every snapshot a column, the price axis across the levels, the level sizes as bar heights and the active snapshot in the accent tone

The depth history as a 3D order book cube

import { bookCubeFromHistory, paintBookCube, scene3dCamera } from '@unifin/chart-core/scene3d';

const cube = bookCubeFromHistory(history); // [{ time, levels: [{ price, bid, ask }] }]
paintBookCube(ctx, cube, { width, height, theme, camera: scene3dCamera() });

Both are public entries of @unifin/chart-core; see the core API.

See also

  • Pro edition - the entry point, the budgets and the other Pro surfaces.
  • Terminal panels - the five panel bindings of the same wave.
  • Features - the order flow area in the capability map.
  • Analytic figures - the heatmap painter the depth landscape reuses.
  • API overview - component props and core painter signatures.

On this page