Car service log
Work done and to come along the odometer, and how far the next one is. Good for maintenance books, fleets and used car listings.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/themes';
const spec = {
type: 'carservice',
odometer: 75510,
format: { currency: 'EUR' },
events: [
{ name: 'Service', at: 15000, kind: 'service', cost: 189, date: '2022-03' },
{ name: 'Inspection', at: 28000, kind: 'inspection', cost: 80, date: '2023-01' },
{ name: 'Service', at: 30000, kind: 'service', cost: 166, date: '2023-02' },
{ name: 'Tyres', at: 42000, kind: 'tyres', cost: 520, date: '2023-11' },
{ name: 'Service', at: 45000, kind: 'service', cost: 162, date: '2024-04' },
{ name: 'Brakes', at: 58000, kind: 'brakes', cost: 267, date: '2025-01' },
{ name: 'Service', at: 60000, kind: 'service', cost: 211, date: '2025-03' },
{ name: 'Service', at: 75000, kind: 'service' },
{ name: 'Inspection', at: 88000, kind: 'inspection' },
{ name: 'Service', at: 90000, kind: 'service' },
{ name: 'Timing belt', at: 120000, kind: 'repair' },
],
};
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 carservice takes:
/** Work done and to come on a car, along its odometer. */
interface CarServiceSpec extends Base {
type: 'carservice';
/** Distance on the odometer now. */
odometer: number;
/** `km` by default. */
unit?: string;
events: {
name: string;
/** Odometer at the time of the work, or when it is due. */
at: number;
date?: string;
cost?: number;
kind?: 'service' | 'tyres' | 'brakes' | 'inspection' | 'repair' | 'battery';
/** False: planned. True by default for work behind the odometer. */
done?: boolean;
}[];
onItemClick?: (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