Key figure
A figure, its change and its trend. Good for the top of a dashboard.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'kpi',
label: 'Monthly revenue',
value: 4666800,
format: { currency: 'EUR', compact: true, letters: ['K', 'M', 'B'] },
compare: [{ value: 3921254, label: 'last year' }, { value: 4295014, label: 'target' }],
trend: [36.2, 31.8, 30.8, 36.2, 31.8, 32.5, 32.6, 27.4, 23.7, 28, 34.5, 37.8, 35.6, 36.4],
};
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 kpi takes:
interface KpiSpec extends Base {
type: 'kpi';
label: string;
value: number;
/** Where counting starts, 0 by default. */
from?: number;
unit?: string;
/** Compared with it; short form of `compare`. */
previous?: number;
/** One or several figures to compare with: last year, the target… */
compare?: Comparison | Comparison[];
trend?: number[];
color?: string;
/** Colours of good and bad news. */
up?: string;
down?: string;
/** A fall is good news. */
lowerIsBetter?: boolean;
}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