Skip to content

3D polar area chart ​

Wedges of the same angle around a centre, as wide and as high as their value. Good for values over the months or the directions of a compass.

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: 'polar3d',
  data: [
    { name: 'Jan', value: 57 },
    { name: 'Feb', value: 45 },
    { name: 'Mar', value: 25 },
    { name: 'Apr', value: 53 },
    { name: 'May', value: 21 },
    { name: 'Jun', value: 20 },
    { name: 'Jul', value: 65 },
    { name: 'Aug', value: 58 },
    { name: 'Sep', value: 29 },
    { name: 'Oct', value: 31 },
    { name: 'Nov', value: 28 },
    { name: 'Dec', value: 28 },
  ],
};

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

/** Wedges of the same angle around a centre, as high as their value and, by default, as wide too. */
interface Polar3DSpec extends Base3D {
  type: 'polar3d';
  data: Item[];
  /** `value`: the area of a wedge follows its value (default). `equal`: all wedges reach the rim. */
  radius?: 'value' | 'equal';
  /** Height of the highest wedge, as a share of the radius: 0.35 by default. */
  height?: number;
  labels?: boolean;
  legend?: boolean | LegendOptions;
  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