npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

draw-football-pitch-library

v1.0.1

Published

A React component library to draw customizable football (soccer) pitches.

Readme

DrawFootballPitch

🧠 Overview

draw-football-pitch-library is a React component library designed to visualize football (soccer) data. It provides scalable and customizable components to render a full or half football pitch, team formations, and heatmaps.

Whether you're building a match dashboard, tactical analysis tool, or visual story, this library helps you bring football data to life using SVG and context-aware rendering.


✨ Features

  • Realistic, scalable football pitch (horizontal or vertical orientation)
  • Team formations overlay using flexible layout logic
  • Heatmap visualization with SVG circle overlays
  • Support for half-pitch and full-pitch views

TeamFormationLayer

The DrawPitch component is the foundation of the library. It renders a scalable football pitch using SVG and provides pitch geometry and orientation through React Context to child components like formations or heatmaps.

📐 Props

| Prop | Type | Default | Description | | --------------- | ------------- | -------------- | --------------------------------------------------------------- | | width | number/string | 800 | Total pitch width in pixels | | height | number/string | 500 | Total pitch height in pixels | | orientation | string | "horizontal" | Pitch direction: "horizontal" or "vertical" | | grassColor | string | "#007A57" | Background color of the pitch | | lineColor | string | "#fff" | Color for field lines | | lineWidth | number | 1 | Width of all field lines | | goalPostColor | string | "#fff" | Color of the goal area | | cornerR | number | 1 | Radius of corner arcs | | children | ReactNode | null | Additional SVG elements or overlay components (formations etc.) |


The component exposes internal dimensions via PitchContext, accessible by any child:

const { width, height, orientation, axisX, axisY, scalePitch } =
  useContext(PitchContext);
import DrawPitch from "./components/DrawPitch/DrawPitch";

<DrawPitch
  width={800}
  height={500}
  orientation="horizontal"
  grassColor="#007A57"
  lineColor="#fff"
  lineWidth={3}
  goalPostColor="#fff"
  cornerR={3}
/>;

This is the default appearance of the DrawPitch component:

DrawPitch Default


TeamFormationLayer

The TeamFormationLayer component renders a football team’s formation directly on the pitch. It uses the context from DrawPitch to calculate player positions based on the provided formation string, pitch size, and orientation.

📐 Props

| Prop | Type | Default | Description | | ------------ | --------- | ----------- | ----------------------------------------------------------------------- | | formation | string | "4-3-3" | Formation string (excluding GK), e.g. "4-4-2", "3-5-2" | | isHomeTeam | boolean | true | If true, renders team on the left/top side of the pitch | | color | string | "#3366FF" | Fill color for player circles (defaults to blue/red based on home/away) | | radius | number | 8 | Radius (in px) for each player circle | | fullPitch | boolean | false | If true, renders players across the full pitch instead of half |


import TeamFormationLayer from "./components/layers/TeamFormation/TeamFormationLayer";

<TeamFormationLayer
  formation="4-4-2"
  isHomeTeam={true}
  color="#3333cc"
  radius={8}
  fullPitch={false}
/>;

This is the appearance of the TeamFormationLayer component:

TeamFormationLayer


HeatmapLayer

he HeatmapLayer component renders heatmap data as SVG circles on top of the football pitch. It takes an array of { x, y } points (as percentages of pitch dimensions) and visualizes them using customizable color, radius, and opacity.

It uses the pitch context from DrawPitch to ensure accurate scaling and orientation for each heat point.

Use this component to visualize:

  • Player activity zones
  • Ball touch locations
  • Tactical intensity areas

📐 Props

| Prop | Type | Default | Description | | --------- | -------- | ------------ | --------------------------------------------------------------------------------- | | data | Array | required | Array of heat points { x, y, value? } where x and y are percentages (0–100) | | color | string | "#F7A82D" | Fill color for heatmap circles | | radius | number | 10 | Radius (in px) for each heat circle | | opacity | number | 0.5 | Opacity of the heat circles (0 to 1) |


import HeatmapLayer from "./components/layers/HeatMap/HeatmapLayer";

<HeatmapLayer data={heatmapData} color="#F7A82D" radius={10} opacity={0.5} />;

This is the appearance of the HeatmapLayer component:

HeatmapLayer


🖼️ Examples

Here are additional visual examples using the DrawPitch system:

✅ Basic Pitch Rendering

DrawPitch

🔷 Team Formation Example

TeamFormation

🔥 Heatmap Overlay Example

Heatmap


Enjoy visualizing dynamic football formations and match data with precision and style! ⚽