computeMomentumBars()
function computeMomentumBars(samples, range?): MomentumBar[];Defined in: packages/core/src/momentum/bars.ts:51
Turns samples at arbitrary intervals into bars.
A bar runs from its sample's minute to the next sample's minute. That is what makes uneven intervals draw honestly: a sample taken every minute draws a thin bar and one taken every five draws a wide one, and neither leaves a gap or an overlap. A fixed-width bar centred on each minute would do both on uneven data.
The last bar has no next sample to end at, so it takes the median interval of the rest. The median rather than the mean, so one long gap in an otherwise regular series doesn't inflate the final bar. A single sample has no interval to measure and gets one minute.
Two samples at the same minute collapse to the later one: the earlier
would span zero minutes and is dropped. Non-finite samples are dropped
rather than propagated, so one NaN in a feed loses that interval, not
the match.
range clips bars to a period, so a last bar can't run past full time
and a stray sample from outside the period draws nothing.
Parameters
| Parameter | Type |
|---|---|
samples | readonly MomentumSample[] |
range? | MomentumRange |