Skip to content

3D building ​

A building whose floors are coloured by their value, the ground floor first. Good for occupancy, energy or rent floor by floor, for real estate.

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: 'building3d',
  data: [
    { name: 'Ground', value: 69 },
    { name: 'Floor 1', value: 60 },
    { name: 'Floor 2', value: 46 },
    { name: 'Floor 3', value: 66 },
    { name: 'Floor 4', value: 43 },
    { name: 'Floor 5', value: 42 },
    { name: 'Floor 6', value: 75 },
    { name: 'Floor 7', value: 70 },
  ],
};

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

/** A building whose floors are coloured by their value (occupancy, energy…); the first item is the ground floor. */
interface Building3DSpec extends Base3D {
  type: 'building3d';
  data: { name: string; value: number | null; color?: string; label?: string; id?: string }[];
  /** Colours from the lowest to the highest value. */
  colors?: string[];
  /** Lowest and highest value of the colour scale. */
  min?: number;
  max?: number;
  /** Width and depth of the building, in floor heights: [4, 2.6] by default. */
  footprint?: [number, number];
  /** Windows along the width of a floor: 6 by default, 0 for none. */
  windows?: number;
  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