Skip to main content

SurfaceChart

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A 3D surface chart that renders z=f(x,y) as an isometric projection. The surface is drawn as filled quadrilateral faces with grayscale shading based on height.

The surface keeps its proportions: it fills as much of its box as it can, and in a widget's stored preview laid out at another size it scales evenly, labels included, to fit.

Import​

import { SurfaceChart } from "~lib/charts/surface-chart";

Props​

NameTypeRequiredDefaultDescription
datanumber[][]YesN/A2D grid of z-values (data[row][col])
widthnumber | stringNo400Container width
heightnumber | stringNo400Container height
wireframebooleanNotrueShow wireframe grid lines
showValuesbooleanNofalseShow z-values on faces
azimuthnumberNo45Horizontal rotation in degrees
elevationnumberNo30Vertical tilt in degrees
axisobjectNoN/AAxis configuration (see below)

Axis Configuration​

axis accepts x, y, and z sub-objects. The x and y axes support:

NameTypeDescription
visiblebooleanShow axis line and auto-generated ticks
namestringLabel displayed along the axis
minnumberMinimum tick value (default: 0)
maxnumberMaximum tick value (default: grid size)
gridbooleanShow dashed grid lines on the base plane

The z axis supports visible, name, and grid. Tick values are auto-generated from the data range.

Data format: data[row][col] represents the z-value (height) at that grid position. Requires at least a 2x2 grid; rows of different lengths are cut to the shortest.

Examples​

Default​

Open Default in Storybook

Gaussian Peak​

Open Peak in Storybook

Saddle Point​

Open Saddle in Storybook

With Axes​

Open With Axes in Storybook

With Axes and Labels​

Open With Axes And Labels in Storybook

With Grid Lines​

Open With Grid in Storybook

Large Grid​

Open Large Grid in Storybook

See Also​