Skip to content

Tennis scoreboard ​

Games of each set, tie-breaks, the server and the winner, then the statistics of both players face to face. Good for match results and reports.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'tennis',
  players: [{ name: 'Yasmine Haddad', seed: 3 }, { name: 'Clara Morel', seed: 8 }],
  sets: [[6, 3], [6, 7], [7, 6]],
  tiebreaks: [null, 4, 3],
  stats: [
    { name: 'Aces', values: [6, 1] },
    { name: 'Double faults', values: [1, 4], lowerIsBetter: true },
    { name: 'First serves in', values: [64, 55], unit: ' %' },
    { name: 'Break points won', values: [3, 1] },
    { name: 'Winners', values: [26, 29] },
    { name: 'Unforced errors', values: [16, 29], lowerIsBetter: true },
  ],
};

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

/** A tennis match: games of each set, tie-breaks, who serves, and statistics. */
interface TennisSpec extends Base {
  type: 'tennis';
  players: [Side & { seed?: number }, Side & { seed?: number }];
  /** Games of each set: [first player, second player]. */
  sets: [number, number][];
  /** Points of the loser of each tie-break, or null. */
  tiebreaks?: (number | null)[];
  /** 0 or 1: the player serving, while the match goes on. */
  serving?: 0 | 1;
  /** Finished: the winner gets a tick. True by default. */
  finished?: boolean;
  stats?: { name: string; values: [number, number]; unit?: string; 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