Skip to content

3D pyramid ​

A pyramid cut into layers as high as their value, the first one at the top. Good for levels of a hierarchy or of a population.

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: 'pyramid3d',
  data: [
    { name: 'Leaders', value: 7 },
    { name: 'Managers', value: 18 },
    { name: 'Leads', value: 29 },
    { name: 'Seniors', value: 64 },
    { name: 'Juniors', value: 66 },
  ],
};

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

/** A pyramid cut into layers; the first item is at the top. */
interface Pyramid3DSpec extends Base3D {
  type: 'pyramid3d';
  data: Item[];
  /** `value`: each layer as high as its value (default). `equal`: layers of the same height. */
  sizing?: 'value' | 'equal';
  /** Square (default) or round. */
  shape?: 'square' | 'round';
  /** Room between two layers, as a share of the height: 0.02 by default. */
  gap?: number;
  onItemClick?: (id: string) => void;
}

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