Skip to content

League table ​

Rank, games, goals, points and the last results of each team, with the zones of the table. Good for championships, leagues and sales contests.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'league',
  teams: [
    { name: 'Tunis', won: 8, drawn: 4, lost: 6, for: 20, against: 18, form: ['W', 'W', 'D', 'D', 'W'] },
    { name: 'Sfax', won: 5, drawn: 3, lost: 10, for: 14, against: 30, form: ['W', 'D', 'W', 'D', 'W'] },
    { name: 'Sousse', won: 5, drawn: 9, lost: 4, for: 12, against: 13, form: ['D', 'D', 'L', 'W', 'D'] },
    { name: 'Bizerte', won: 8, drawn: 9, lost: 1, for: 20, against: 8, form: ['D', 'W', 'L', 'W', 'D'] },
    { name: 'Gabes', won: 13, drawn: 4, lost: 1, for: 31, against: 5, form: ['L', 'D', 'D', 'D', 'W'] },
    { name: 'Kairouan', won: 13, drawn: 2, lost: 3, for: 30, against: 10, form: ['W', 'W', 'W', 'D', 'L'] },
    { name: 'Tozeur', won: 8, drawn: 5, lost: 5, for: 25, against: 13, form: ['W', 'D', 'L', 'L', 'L'] },
    { name: 'Nabeul', won: 6, drawn: 10, lost: 2, for: 20, against: 11, form: ['L', 'W', 'W', 'L', 'W'] },
    { name: 'Mahdia', won: 10, drawn: 5, lost: 3, for: 31, against: 9, form: ['W', 'L', 'D', 'L', 'L'] },
    { name: 'Djerba', won: 4, drawn: 11, lost: 3, for: 15, against: 10, form: ['L', 'D', 'W', 'L', 'D'] },
  ],
  zones: [
    { from: 1, to: 2, label: 'Promotion' },
    { from: 3, to: 4, label: 'Play-offs' },
    { from: 9, to: 10, label: 'Relegation' },
  ],
};

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

/** A league table, sorted by points. */
interface LeagueSpec extends Base {
  type: 'league';
  teams: {
    name: string;
    won: number;
    drawn: number;
    lost: number;
    /** Goals scored and let in. */
    for?: number;
    against?: number;
    /** Counted from the results when missing: 3 for a win, 1 for a draw. */
    points?: number;
    /** The last results, the oldest first. */
    form?: ('W' | 'D' | 'L')[];
    color?: string;
  }[];
  /** Ranks from `from` to `to`: promotion, cups, relegation. */
  zones?: { from: number; to: number; label: string; color?: string }[];
  onTeamClick?: (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