Skip to content

Team stats face-off ​

Two teams face to face, figure by figure, each bar as long as its share. Good for match statistics: possession, shots, fouls.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'faceoff',
  home: { name: 'Sfax Lions', color: '#c8384f' },
  away: { name: 'Bizerte Port', color: '#2f5fae' },
  stats: [
    { name: 'Possession', home: 56, away: 44, unit: ' %' },
    { name: 'Shots', home: 13, away: 6 },
    { name: 'Shots on target', home: 6, away: 2 },
    { name: 'Expected goals', home: 1.34, away: 1.05 },
    { name: 'Corners', home: 6, away: 2 },
    { name: 'Passes', home: 453, away: 328 },
    { name: 'Fouls', home: 9, away: 17, lowerIsBetter: true },
    { name: 'Yellow cards', home: 0, away: 3, 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 faceoff takes:

/** Two teams face to face, figure by figure. */
interface FaceOffSpec extends Base {
  type: 'faceoff';
  home: Side;
  away: Side;
  stats: { name: string; home: number; away: number; unit?: string; lowerIsBetter?: boolean }[];
}

/** A team or a player facing another. */
interface Side {
  name: string;

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