Table plan
Tables of a room and their seats, by state. Good for restaurants, weddings, classrooms.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'tables',
tables: [
{ name: 'T1', x: 0, y: 0, seats: 4, state: 'busy', round: false },
{ name: 'T2', x: 33, y: 0, seats: 2, state: 'busy', round: true },
{ name: 'T3', x: 66, y: 0, seats: 2, state: 'free', round: true },
{ name: 'T4', x: 99, y: 0, seats: 6, state: 'reserved', round: false },
{ name: 'T5', x: 0, y: 50, seats: 4, state: 'free', round: true },
{ name: 'T6', x: 33, y: 50, seats: 4, state: 'free', round: true },
{ name: 'T7', x: 66, y: 50, seats: 8, state: 'free', round: false },
{ name: 'T8', x: 99, y: 50, seats: 6, state: 'free', round: true },
{ name: 'T9', x: 0, y: 100, seats: 4, state: 'free', round: true },
{ name: 'T10', x: 33, y: 100, seats: 4, state: 'reserved', round: false },
{ name: 'T11', x: 66, y: 100, seats: 2, state: 'busy', round: true },
{ name: 'T12', x: 99, y: 100, seats: 4, state: 'busy', round: true },
],
};
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 tables takes:
/** Tables of a room, with their seats. */
interface TablesSpec extends Base {
type: 'tables';
/** Places from 0 to 100. */
tables: { name: string; x: number; y: number; seats: number; state: string; round?: boolean; detail?: string }[];
colors?: Record<string, string>;
onTableClick?: (name: string) => void;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More