Skip to content

3D heatmap ​

Raised tiles on a grid, each one as high and as dark as its value, with a colour scale. Good for activity by day and hour, when the peaks have to stand out.

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: 'heatmap3d',
  columns: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
  rows: ['Morning', 'Noon', 'Afternoon', 'Evening'],
  values: [
    [43, 39, 31, 42, 29, 9, 26],
    [69, 57, 58, 57, 57, 63, 31],
    [47, 25, 39, 33, 34, 30, 6],
    [40, 45, 40, 54, 31, 18, 23],
  ],
};

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

/** A heatmap of raised tiles: each one as high and as dark as its value. */
interface Heatmap3DSpec extends Base3D {
  type: 'heatmap3d';
  columns: string[];
  rows: string[];
  values: (number | null)[][];
  /** Colours from the lowest to the highest value. */
  colors?: string[];
  /** Height of the highest tile, as a share of the side of a cell: 0.6 by default. */
  height?: number;
}

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