PitchKit
API Reference@pitchkit/coreFunctions

stackOffsets()

function stackOffsets(
   xs, 
   size, 
   step
): number[];

Defined in: packages/core/src/momentum/stack.ts:19

Offsets markers that would overlap so they fan out instead of overprinting.

Events cluster: a goal, a booking and a substitution inside the same minute all want the same spot on a one-row icon strip. Rather than add rows, a crowded run is spread into a shallow stack: each marker sits step pixels right of the one before it, and a later one paints over an earlier one, like a hand of cards.

A marker that is already at least size pixels from the last one is left exactly where it is. A run that had to move is then re-centred on where its markers really were, so a stack straddles its minute rather than drifting off to one side of it.

Returns an x per input, in the input's order, so the caller doesn't have to sort to use it. Paint in ascending x to get the stacking the layout assumes.

Parameters

ParameterType
xsreadonly number[]
sizenumber
stepnumber

Returns

number[]

On this page