Skip to content

Tournament bracket ​

Matches round after round, to the final. Good for cups and knock-out games.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'bracket',
  rounds: [
    {
      name: 'Quarter-finals',
      matches: [
        { home: 'Kairouan', away: 'Gabes', score: [1, 2] },
        { home: 'Sousse', away: 'Mahdia', score: [4, 0] },
        { home: 'Djerba', away: 'Sfax', score: [2, 3] },
        { home: 'Bizerte', away: 'Tunis', score: [2, 3] },
      ],
    },
    {
      name: 'Semi-finals',
      matches: [
        { home: 'Gabes', away: 'Sousse', score: [1, 3] },
        { home: 'Sfax', away: 'Tunis', score: [0, 2] },
      ],
    },
    { name: 'Final', matches: [{ home: 'Sousse', away: 'Tunis', score: [2, 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 bracket takes:

/** Matches of a tournament, the first round first. */
interface BracketSpec extends Base {
  type: 'bracket';
  rounds: { name?: string; matches: { home: string; away: string; score?: [number, number] }[] }[];
}

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