Skip to content

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: 46668,
  unit: ' €',
  previous: 39213,
  trend: [42.3, 38.5, 34.1, 33.1, 38.5, 34.1, 34.8, 34.9, 29.7, 25.9, 30.3, 36.7, 40, 37.8],
};

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;
  unit?: string;
  /** Compared with it. */ previous?: number;
  trend?: number[];
  color?: string;
  /** A fall is good news. */ lowerIsBetter?: boolean;
}

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