Skip to content

Scorecard ​

Names, figures, bars and arrows in a table. Good for a short list of results and how each one changed.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'scorecard',
  headings: ['Shop', 'Sales', 'vs last month'],
  sort: true,
  data: [
    { name: 'Kairouan', value: 342, previous: 304 },
    { name: 'Gabes', value: 866, previous: 701 },
    { name: 'Sousse', value: 634, previous: 507 },
    { name: 'Mahdia', value: 489, previous: 440 },
    { name: 'Djerba', value: 372, previous: 420 },
    { name: 'Sfax', value: 211, previous: 209 },
  ],
};

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 scorecard takes:

/** A table of names, figures, bars and changes. */
interface ScorecardSpec extends Base {
  type: 'scorecard';
  data: { name: string; value: number; previous?: number; color?: string }[];
  unit?: string;
  color?: string;
  /** A fall is good news. */
  lowerIsBetter?: boolean;
  up?: string;
  down?: string;
  /** Headings of the name, value and change columns. */
  headings?: [string, string, string];
  sort?: 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