Football pitch and line-up
Two teams on a ground, by formation, and the path of the ball. Handball and basketball too. Good for line-ups, tactics and match reports.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'pitch',
teams: [
{
color: '#c8384f',
name: 'Reds',
formation: '4-4-2',
players: [
{ name: 'Nader', number: 1 },
{ name: 'Hedi', number: 2 },
{ name: 'Rami', number: 3 },
{ name: 'Sami', number: 4 },
{ name: 'Adel', number: 5 },
{ name: 'Omar', number: 6 },
{ name: 'Bilel', number: 7 },
{ name: 'Amine', number: 8 },
{ name: 'Salim', number: 9 },
{ name: 'Yassin', number: 10 },
{ name: 'Karim', number: 11 },
],
},
{
color: '#2f5fae',
name: 'Blues',
formation: '4-3-3',
players: [
{ name: 'Salim', number: 1 },
{ name: 'Omar', number: 2 },
{ name: 'Amine', number: 3 },
{ name: 'Nader', number: 4 },
{ name: 'Karim', number: 5 },
{ name: 'Hedi', number: 6 },
{ name: 'Bilel', number: 7 },
{ name: 'Sami', number: 8 },
{ name: 'Adel', number: 9 },
{ name: 'Rami', number: 10 },
{ name: 'Yassin', number: 11 },
],
},
],
path: [[50, 50], [38, 30], [58, 22], [74, 48], [96, 50]],
};
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 pitch takes:
/** A sports ground with one or two teams, and what the ball did. */
interface PitchSpec extends Base {
type: 'pitch';
sport?: 'football' | 'handball' | 'basketball';
teams: PitchTeam[];
/** The ball, from 0 to 100 along and across the ground. */
path?: [number, number][];
}
interface PitchTeam {
name: string;Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More