Skip to content

Floor plan ​

The rooms of a home, at scale, with their area. Good for real estate, offices and shops.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'floorplan',
  unit: ' €/m²',
  rooms: [
    { name: 'Living room', x: 0, y: 0, width: 6, depth: 4.6, value: 4500 },
    { name: 'Kitchen', x: 6, y: 0, width: 3.4, depth: 3, value: 4000 },
    { name: 'Hall', x: 6, y: 3, width: 3.4, depth: 1.6, value: 3300 },
    { name: 'Bedroom', x: 0, y: 4.6, width: 4.2, depth: 3.8, value: 4300 },
    { name: 'Bathroom', x: 4.2, y: 4.6, width: 2.2, depth: 3.8, value: 3200 },
    { name: 'Office', x: 6.4, y: 4.6, width: 3, depth: 3.8, value: 3200 },
  ],
};

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

/** The rooms of a home, at scale. */
interface FloorPlanSpec extends Base {
  type: 'floorplan';
  rooms: Room[];
  /** Writes the area of each room. */
  area?: boolean;
  unit?: string;
  onRoomClick?: (name: string) => void;
}

interface Room {
  name: string;

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