Skip to content

3D stacked column chart ​

Parts piled up into a column for each category. Good for a total and what it is made of, on a cover page.

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: 'stacked3d',
  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
  series: [
    { name: 'Bread', data: [31, 26, 17, 29, 15, 15] },
    { name: 'Fruit', data: [34, 31, 18, 19, 18, 18] },
    { name: 'Cheese', data: [48, 11, 35, 10, 26, 19] },
  ],
};

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

/** Stacked columns standing on a floor; `percent` makes every column 100 % high. */
interface Stacked3DSpec extends Base3D {
  type: 'stacked3d';
  categories: string[];
  series: Series3D[];
  shape?: 'box' | 'cylinder';
  percent?: boolean;
  width?: number;
  max?: number;
  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;
}

interface Series3D {
  name: 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