@pitchkit/core
The zero-dependency, framework-agnostic engine behind PitchKit: pitch dimensions, coordinate transforms, the scene/layer model, geometry algorithms, heatmap binning, and the maths behind its non-pitch charts.
Docs: pitchkitjs.com
Most people want
@pitchkit/reactinstead. That's the supported rendering surface. This package is the maths underneath it — useful directly if you're computing pitch geometry outside React, or building bindings for another framework.
Early days — pre-
1.0. The API isn't stable yet.
Install
npm install @pitchkit/coreZero runtime dependencies. ESM, tree-shakeable, ships its own types.
What's inside
Pitch dimensions — statsbomb, opta, uefa, skillcorner, wyscout, metrica and impect, each in the
provider's real coordinate space, sourced from mplsoccer's published constants so real event data
aligns exactly.
import { getPitchDimensions, cropForHalf } from "@pitchkit/core";
const dimensions = getPitchDimensions("statsbomb"); // 120 × 80, markings included
const half = cropForHalf(dimensions); // crop window for the attacking halfCoordinate transforms — map provider coordinates to pixels, with orientation, padding and cropping handled for you.
import { createPixelTransform } from "@pitchkit/core";
const transform = createPixelTransform({ dimensions, viewport, orientation: "vertical" });createStandardizeTransform() converts between providers' coordinate spaces.
Geometry — computeConvexHull, computeVoronoiCells, computeGoalAngle,
computeFlowBins, computePolygonCentroid, plus arc/arrow/comet path maths.
Density — computeHeatmapBins (uniform grid), computePositionalBins (Juego de Posición
zones), computeHexBins (hexagonal lattice) and computeKdeGrid (Gaussian KDE) for binning
(count or weighted), createColorScale for a dependency-free colour ramp, and
renderDensityLayersToCanvas for painting to a devicePixelRatio-aware canvas.
Chart maths — the numbers behind <RaceChart>, <MomentumChart>, <RadarChart> and
<PizzaChart>, none of which touch a pitch: createLinearScale and niceTicks,
computeCumulativeSeries and stepPath, computeMomentumBars, and the polar helpers
axisAngle, polarPoint, wedgeAngles and annularSectorPath.
Theming — pitchTokens (CSS variable names, for autocomplete) and partStyle.
Note on the SVG renderer
svgRenderer / renderSceneToSVGElement are exported but internal — they exist to support
this repo's own dev harness, not as a supported vanilla-JS consumption path, and new mark types
are not added to them. Use @pitchkit/react to render. (Canvas heatmap rendering is
unaffected — @pitchkit/react's <Heatmap> calls straight into it.)
Links
- Documentation & gallery
- Repository
- Issues
- X · Instagram
@pitchkit/react— the React bindings
Licence
MIT © Yohahn Ribeiro
Interfaces
- AnnotateLayer
- Arc
- ArrowsLayer
- ChartFrame
- ChartPadding
- Circle
- CometLayer
- ConvexHullLayer
- CropWindow
- FlowBin
- FlowLayer
- FlowVector
- GoalAngleLayer
- GoalDimensionMarker
- GoalFrame
- GoalGeometry
- GoalGroundMarking
- GoalLayout
- GoalPoint
- GoalRect
- GoalSegment
- HeatmapBin
- HeatmapLayer
- HexBin
- HexbinLayer
- KdeGrid
- KdeLayer
- LabelPlacement
- Line
- LinearScale
- MomentumBar
- MomentumPanel
- MomentumRange
- MomentumSample
- NormalisedValue
- PitchAppearance
- PitchDimensionOverrides
- PitchDimensions
- PitchGeometry
- PitchMarkings
- PixelTransform
- PolarRange
- PolygonLayer
- PositionalBin
- PositionalHeatmapLayer
- PositionalZone
- RaceEvent
- RacePoint
- RaceSeriesData
- Rect
- Renderer
- RenderHeatmapOptions
- ScatterLayer
- Scene
- Viewport
- ViewportPadding
- VoronoiLayer
- Wedge
Type Aliases
- Accessor
- GoalFrameId
- GoalMarkerUnits
- GoalType
- LabelRotation
- Layer
- Orientation
- PitchOrigin
- PitchStripes
- PitchTypeId
- Point
- PositionalLayout
- YDirection
Variables
- ARROW_HEAD_HALF_ANGLE
- canvasRenderer
- GLYPH_WIDTH
- GOAL_CAMERA_DISTANCE
- GOAL_CAMERA_HEIGHT
- GOAL_FRAMES
- GOAL_HEIGHT_METRES
- GOAL_VIEW_ASPECT
- GOAL_VIEW_GROUND
- GOAL_VIEW_HALF_WIDTH
- GOAL_VIEW_TOP
- GOAL_WIDTH_METRES
- LABEL_LINE_HEIGHT
- PITCH_DIMENSIONS
- pitchTokens
- renderHeatmapLayersToCanvas
- svgRenderer
Functions
- annularSectorPath
- arcPathData
- arcSweepFlag
- axisAngle
- barAtMinute
- clipMomentumBars
- clipPolygonByHalfPlane
- computeArrowHeadCorners
- computeChartFrame
- computeCometQuad
- computeConvexHull
- computeCumulativeSeries
- computeFlowBins
- computeGoalAngle
- computeGoalBox
- computeGoalGeometry
- computeGoalLayout
- computeHeatmapBins
- computeHexBins
- computeKdeGrid
- computeMomentumBars
- computePitchGeometry
- computePolygonCentroid
- computePositionalBins
- computePositionalZones
- computeStripeBands
- computeVoronoiCells
- createColorScale
- createLinearScale
- createPixelTransform
- createStandardizeTransform
- cropForHalf
- displayUnitScale
- fromGoalMetres
- getPitchDimensions
- goalBoxDepth
- goalDimensionLabels
- goalPlaneToPixel
- goalPoint
- groupByPeriod
- hexCorners
- isPeriod
- labelBox
- labelMargin
- labelPlacement
- layoutMomentumPanels
- matchMinuteTicks
- medianBarWidth
- metricLabelLines
- minuteToX
- momentumExtent
- nearestAxis
- niceTicks
- nominalPeriodRange
- normaliseMetric
- overlayOrder
- partStyle
- pitchGoalBoxDepth
- polarLayout
- polarPoint
- projectGround
- racePeriodRanges
- renderDensityLayersToCanvas
- renderSceneToSVGElement
- resolve
- resolveEndTime
- resolvePeriodRange
- resolveStripeCount
- ringPath
- ringSteps
- ringValues
- selectGoal
- silvermanBandwidth
- splitWedge
- stackOffsets
- stepAreaPath
- stepPath
- textWidth
- toGoalMetres
- unevenBarWidths
- valueAtTime
- valueBoxSpot
- wedgeAngles
- wedgeLane
- wedgeMid
- wrapLabel
- xToMinute