Skip to content

3D gauge ​

A dial with a thick ring, a bevel, coloured bands, a target and a needle. Good for one figure against its range, on a cover or a dashboard that has to strike.

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: 'gauge3d',
  value: 59,
  target: 80,
  unit: ' %',
  name: 'Goal 80 %',
  bands: [{ to: 50, color: '#e9c46a', name: 'Low' }, { to: 100, color: '#8ecae6', name: 'Good' }],
};

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

/** A dial with a thick ring, a bevel and a needle. */
interface Gauge3DSpec extends Base3D {
  type: 'gauge3d';
  value: number;
  /** 0 by default. */
  min?: number;
  /** 100 by default. */
  max?: number;
  color?: string;
  /** Parts of the ring in their own colour, each up to its `to`. */
  bands?: { to: number; color?: string; name?: string }[];
  /** A mark on the ring. */
  target?: number;
  name?: string;
  unit?: string;
}

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