Skip to content

3D waterfall chart ​

Blocks that rise and fall from one total to the next. Good for a bridge from one figure to another, on a slide.

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

In your framework

import { Chart } from 'nervure/react';
import 'nervure/3d';

const spec = {
  type: 'waterfall3d',
  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 waterfall3d takes:

/** Steps that rise and fall from one total to the next, as blocks. */
interface Waterfall3DSpec extends Base3D {
  type: 'waterfall3d';
  /** A step adds its value to the running total; a `total` stands from the floor at its own value. */
  data: { name: string; value: number; total?: boolean; color?: string }[];
  up?: string;
  down?: string;
  totalColor?: string;
  /** Share of a category taken by its block, from 0.2 to 1: 0.6 by default. */
  width?: number;
  /** Lines from the top of a block to the next: true by default. */
  connectors?: boolean;
  legend?: boolean | LegendOptions;
}

interface Base3D extends Base {
  /** Where the eye stands, in degrees: `azimuth` turns around the vertical axis, `elevation` rises from the floor (0) to straight above (90). */
  view?: { azimuth?: number; elevation?: number };
  /** Drag the chart, or focus its turn button and use the arrow keys, to turn the view. Home on the button goes back to `view`. */
  rotate?: boolean;
}

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