Skip to content

Waterfall chart ​

Gains and losses between two totals. Good for explaining a profit, a budget or a head count.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'waterfall',
  data: [
    { name: 'Start', value: 126, total: true },
    { name: 'New', value: 36 },
    { name: 'Upsell', value: 15 },
    { name: 'Lost', value: -29 },
    { name: 'Refunds', value: -8 },
    { name: 'End', value: 140, total: true },
  ],
};

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 waterfall takes:

/** Steps from a start to an end; `total: true` restarts from zero. */
interface WaterfallSpec extends Base {
  type: 'waterfall';
  data: { name: string; value: number; total?: boolean; color?: string }[];
  up?: string;
  down?: string;
  totalColor?: string;
}

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