Skip to content

3D wireframe ​

The same surface as a mesh of lines, the far side hidden. Good for a light picture of a surface, printed or in a report.

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: 'surface3d',
  wireframe: true,
  z: [
    [3.5, 6.7, 10.8, 14.7, 17.6, 19, 19.3, 19.1, 19, 19.1, 19.3, 19, 17.6, 14.7, 10.8, 6.7, 3.5],
    [6.7, 11.5, 16, 18.9, 19.1, 17.2, 14.3, 11.9, 11, 11.9, 14.3, 17.2, 19.1, 18.9, 16, 11.5, 6.7],
    [
      10.8, 16, 19.1, 18.3, 13.6, 6.6, -0.1, -4.8, -6.4, -4.8, -0.1, 6.6, 13.6, 18.3, 19.1, 16,
      10.8,
    ],
    [
      14.7, 18.9, 18.3, 11.9, 1.4, -9.8, -18.5, -23.4, -24.9, -23.4, -18.5, -9.8, 1.4, 11.9,
      18.3, 18.9, 14.7,
    ],
    [
      17.6, 19.1, 13.6, 1.4, -13.3, -24.9, -30.7, -31.9, -31.8, -31.9, -30.7, -24.9, -13.3, 1.4,
      13.6, 19.1, 17.6,
    ],
    [
      19, 17.2, 6.6, -9.8, -24.9, -31.8, -29, -22, -18.4, -22, -29, -31.8, -24.9, -9.8, 6.6,
      17.2, 19,
    ],
    [
      19.3, 14.3, -0.1, -18.5, -30.7, -29, -14.2, 3.6, 11.4, 3.6, -14.2, -29, -30.7, -18.5, -0.1,
      14.3, 19.3,
    ],
    [
      19.1, 11.9, -4.8, -23.4, -31.9, -22, 3.6, 30.5, 41.9, 30.5, 3.6, -22, -31.9, -23.4, -4.8,
      11.9, 19.1,
    ],
    [
      19, 11, -6.4, -24.9, -31.8, -18.4, 11.4, 41.9, 54.8, 41.9, 11.4, -18.4, -31.8, -24.9, -6.4,
      11, 19,
    ],
    [
      19.1, 11.9, -4.8, -23.4, -31.9, -22, 3.6, 30.5, 41.9, 30.5, 3.6, -22, -31.9, -23.4, -4.8,
      11.9, 19.1,
    ],
    [
      19.3, 14.3, -0.1, -18.5, -30.7, -29, -14.2, 3.6, 11.4, 3.6, -14.2, -29, -30.7, -18.5, -0.1,
      14.3, 19.3,
    ],
    [
      19, 17.2, 6.6, -9.8, -24.9, -31.8, -29, -22, -18.4, -22, -29, -31.8, -24.9, -9.8, 6.6,
      17.2, 19,
    ],
    [
      17.6, 19.1, 13.6, 1.4, -13.3, -24.9, -30.7, -31.9, -31.8, -31.9, -30.7, -24.9, -13.3, 1.4,
      13.6, 19.1, 17.6,
    ],
    [
      14.7, 18.9, 18.3, 11.9, 1.4, -9.8, -18.5, -23.4, -24.9, -23.4, -18.5, -9.8, 1.4, 11.9,
      18.3, 18.9, 14.7,
    ],
    [
      10.8, 16, 19.1, 18.3, 13.6, 6.6, -0.1, -4.8, -6.4, -4.8, -0.1, 6.6, 13.6, 18.3, 19.1, 16,
      10.8,
    ],
    [6.7, 11.5, 16, 18.9, 19.1, 17.2, 14.3, 11.9, 11, 11.9, 14.3, 17.2, 19.1, 18.9, 16, 11.5, 6.7],
    [3.5, 6.7, 10.8, 14.7, 17.6, 19, 19.3, 19.1, 19, 19.1, 19.3, 19, 17.6, 14.7, 10.8, 6.7, 3.5],
  ],
};

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

/** A surface over a grid: `z[row][column]`, coloured by height. */
interface Surface3DSpec extends Base3D {
  type: 'surface3d';
  /** Heights, one row for each `y`, one value for each `x`; null leaves a hole. */
  z: (number | null)[][];
  /** Names of the columns of `z`, along the width. */
  x?: string[];
  /** Names of the rows of `z`, along the depth. */
  y?: string[];
  /** Colours from the lowest to the highest value. */
  colors?: string[];
  /** Lines only, without filled faces. */
  wireframe?: boolean;
  /** Names of the three axes. */
  titles?: { x?: string; y?: string; z?: 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