Skip to content

Football shot map ​

Shots on half a pitch, each circle as large as its chance of a goal, filled when it went in. Good for match reports, scouting and finishing.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'shotmap',
  team: 'Sfax Lions',
  color: '#c8384f',
  shots: [
    { x: 50, y: 6, xg: 0.35, result: 'goal', minute: 16, player: 'Karim Ben Ali', id: 'shot-0' },
    { x: 45, y: 5, xg: 0.35, result: 'goal', minute: 55, player: 'Karim Ben Ali', id: 'shot-1' },
    { x: 33, y: 11, xg: 0.08, result: 'saved', minute: 86, player: 'Amine Gharbi', id: 'shot-2' },
    { x: 57, y: 5, xg: 0.31, result: 'saved', minute: 23, player: 'Bilel Trabelsi', id: 'shot-3' },
    { x: 21, y: 17, xg: 0.02, result: 'missed', minute: 75, player: 'Rami Jaziri', id: 'shot-4' },
    { x: 43, y: 19, xg: 0.05, result: 'saved', minute: 50, player: 'Hedi Mansour', id: 'shot-5' },
    { x: 23, y: 25, xg: 0.02, result: 'missed', minute: 86, player: 'Adel Haddad', id: 'shot-6' },
    { x: 41, y: 9, xg: 0.17, result: 'missed', minute: 42, player: 'Karim Ben Ali', id: 'shot-7' },
    { x: 40, y: 32, xg: 0.02, result: 'saved', minute: 22, player: 'Amine Gharbi', id: 'shot-8' },
    { x: 36, y: 5, xg: 0.18, result: 'blocked', minute: 51, player: 'Karim Ben Ali', id: 'shot-9' },
    { x: 64, y: 8, xg: 0.14, result: 'missed', minute: 68, player: 'Omar Saidi', id: 'shot-10' },
    { x: 71, y: 15, xg: 0.04, result: 'missed', minute: 55, player: 'Adel Haddad', id: 'shot-11' },
    { x: 39, y: 14, xg: 0.08, result: 'saved', minute: 69, player: 'Omar Saidi', id: 'shot-12' },
    { x: 73, y: 9, xg: 0.06, result: 'blocked', minute: 52, player: 'Sami Mejri', id: 'shot-13' },
    { x: 67, y: 9, xg: 0.1, result: 'missed', minute: 23, player: 'Omar Saidi', id: 'shot-14' },
    { x: 47, y: 13, xg: 0.12, result: 'missed', minute: 4, player: 'Hedi Mansour', id: 'shot-15' },
    { x: 76, y: 26, xg: 0.02, result: 'blocked', minute: 45, player: 'Amine Gharbi', id: 'shot-16' },
  ],
};

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

/** Shots of a team on half a pitch: a circle as large as its chance of a goal, filled when it went in. */
interface ShotMapSpec extends Base {
  type: 'shotmap';
  shots: Shot[];
  team?: string;
  color?: string;
  onItemClick?: (id: string) => void;
}

interface Shot {
  /** Across the pitch, from 0 (left touchline, facing the goal) to 100. */
  x: 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