Car park
Spaces seen from above, free or taken, with charging and accessible bays. Good for car parks, garages and any count of free spaces.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'parking',
rows: [
{
name: 'A',
spaces: [
{ id: 'A1', kind: 'ev', taken: false },
{ id: 'A2', kind: 'ev', taken: true },
{ id: 'A3', taken: true },
{ id: 'A4', taken: true },
{ id: 'A5', taken: true },
{ id: 'A6', taken: true },
{ id: 'A7', taken: true },
null,
{ id: 'A9', taken: true },
{ id: 'A10', taken: true },
{ id: 'A11', taken: true },
{ id: 'A12', taken: true },
{ id: 'A13', taken: true },
{ id: 'A14', taken: false },
],
},
{
name: 'B',
spaces: [
{ id: 'B1', taken: true },
{ id: 'B2', taken: true },
{ id: 'B3', taken: true },
{ id: 'B4', taken: true },
{ id: 'B5', taken: true },
{ id: 'B6', taken: true },
{ id: 'B7', taken: false },
null,
{ id: 'B9', taken: true },
{ id: 'B10', taken: true },
{ id: 'B11', taken: true },
{ id: 'B12', taken: true },
{ id: 'B13', kind: 'reserved', taken: false },
{ id: 'B14', kind: 'reserved', taken: true },
],
},
{
name: 'C',
spaces: [
{ id: 'C1', taken: true },
{ id: 'C2', taken: true },
{ id: 'C3', taken: false },
{ id: 'C4', taken: true },
{ id: 'C5', taken: true },
{ id: 'C6', taken: true },
{ id: 'C7', taken: true },
null,
{ id: 'C9', taken: false },
{ id: 'C10', taken: true },
{ id: 'C11', taken: true },
{ id: 'C12', taken: false },
{ id: 'C13', taken: false },
{ id: 'C14', taken: true },
],
},
{
name: 'D',
spaces: [
{ id: 'D1', kind: 'accessible', taken: true },
{ id: 'D2', kind: 'accessible', taken: false },
{ id: 'D3', taken: true },
{ id: 'D4', taken: true },
{ id: 'D5', taken: true },
{ id: 'D6', taken: true },
{ id: 'D7', taken: false },
null,
{ id: 'D9', taken: true },
{ id: 'D10', taken: true },
{ id: 'D11', taken: true },
{ id: 'D12', taken: true },
{ id: 'D13', taken: true },
{ id: 'D14', taken: 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 parking takes:
/** Car park from above: spaces free and taken, by kind. */
interface ParkingSpec extends Base {
type: 'parking';
/** Rows of spaces from the top; a lane runs after every second row. `null`: a pillar. */
rows: { name: string; spaces: (ParkingSpace | null)[] }[];
onItemClick?: (id: 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