Skip to content

Market depth chart ​

Bids and asks added up from the mid price outwards, as two steps. Good for order books: where buyers and sellers wait, and how thin the market is.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'depth',
  bids: [
    { price: 100.03, size: 10 },
    { price: 99.92, size: 12 },
    { price: 99.78, size: 16 },
    { price: 99.68, size: 29 },
    { price: 99.57, size: 30 },
    { price: 99.43, size: 22 },
    { price: 99.29, size: 23 },
    { price: 99.18, size: 55 },
    { price: 99.08, size: 50 },
    { price: 98.93, size: 48 },
    { price: 98.83, size: 56 },
    { price: 98.72, size: 86 },
    { price: 98.57, size: 40 },
    { price: 98.45, size: 57 },
    { price: 98.34, size: 100 },
    { price: 98.23, size: 42 },
    { price: 98.13, size: 30 },
    { price: 97.99, size: 97 },
    { price: 97.87, size: 49 },
    { price: 97.76, size: 120 },
    { price: 97.62, size: 95 },
    { price: 97.49, size: 110 },
    { price: 97.37, size: 82 },
    { price: 97.24, size: 130 },
  ],
  asks: [
    { price: 100.18, size: 36 },
    { price: 100.28, size: 39 },
    { price: 100.44, size: 36 },
    { price: 100.55, size: 28 },
    { price: 100.66, size: 28 },
    { price: 100.8, size: 23 },
    { price: 100.88, size: 68 },
    { price: 101.01, size: 53 },
    { price: 101.11, size: 39 },
    { price: 101.26, size: 59 },
    { price: 101.37, size: 64 },
    { price: 101.51, size: 71 },
    { price: 101.62, size: 33 },
    { price: 101.75, size: 55 },
    { price: 101.83, size: 82 },
    { price: 101.98, size: 105 },
    { price: 102.07, size: 100 },
    { price: 102.2, size: 112 },
    { price: 102.36, size: 65 },
    { price: 102.46, size: 76 },
    { price: 102.58, size: 110 },
    { price: 102.72, size: 78 },
    { price: 102.84, size: 81 },
    { price: 102.95, size: 155 },
  ],
};

export default function Example() {
  return <Chart spec={spec} style={{ height: 340 }} />;
}

Or import this chart alone: what each import weighs.

Options

Beside the fields shared by every chart (title, format, heading, export…), type depth takes:

/** Market depth: what buyers and sellers wait for, added up from the mid price outwards. */
interface DepthSpec extends Base {
  type: 'depth';
  bids: DepthOrder[];
  asks: DepthOrder[];
  up?: string;
  down?: string;
}

interface DepthOrder {
  price: number;

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it