Skip to content

Medal table ​

Gold, silver and bronze of each country or club, sorted as in the games. Good for games, championships and tournaments.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'medals',
  data: [
    { name: 'Tunis', gold: 5, silver: 3, bronze: 2 },
    { name: 'Sfax', gold: 4, silver: 1, bronze: 1 },
    { name: 'Sousse', gold: 5, silver: 5, bronze: 2 },
    { name: 'Bizerte', gold: 2, silver: 2, bronze: 2 },
    { name: 'Gabes', gold: 9, silver: 0, bronze: 6 },
    { name: 'Kairouan', gold: 0, silver: 4, bronze: 2 },
    { name: 'Tozeur', gold: 2, silver: 7, bronze: 0 },
    { name: 'Nabeul', gold: 4, silver: 5, bronze: 4 },
    { name: 'Mahdia', gold: 7, silver: 2, bronze: 4 },
    { name: 'Djerba', gold: 5, silver: 8, bronze: 2 },
  ],
  top: 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 medals takes:

/** A medal table: gold, then silver, then bronze. */
interface MedalsSpec extends Base {
  type: 'medals';
  data: { name: string; gold: number; silver: number; bronze: number; color?: string }[];
  /** Order by gold first (default) or by the total. */
  sort?: 'gold' | 'total';
  top?: number;
  onItemClick?: (name: string) => void;
}

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