PitchKit
API Reference@pitchkit/coreFunctions

computeCumulativeSeries()

function computeCumulativeSeries(events): RaceSeriesData;

Defined in: packages/core/src/race/cumulative.ts:51

Turns events into a running total, sorted by time.

What this deliberately does not do is synthesise the kick-off and full-time anchors. Those are a rendering concern (stepPath adds them), and keeping them out of points means every point corresponds to a real datum — so markers and tooltips map one-to-one onto the caller's array and never have to special-case two phantom entries.

Events arrive unsorted often enough to be the default assumption: a StatsBomb feed is in event order, which is chronological per period but interleaves the two teams, and filtering one team out leaves gaps rather than disorder. Sorting anyway costs nothing and removes a class of bug where a late-arriving event draws a step backwards.

Non-finite values are dropped rather than propagated: one NaN in a running sum poisons every point after it, and an xG feed with a missing value should lose that shot, not the rest of the match.

Parameters

ParameterType
eventsreadonly RaceEvent[]

Returns

RaceSeriesData

On this page