English
@eightkk/vue-weave / core / aggregateTimeBuckets
Function: aggregateTimeBuckets()
aggregateTimeBuckets<
T>(items,buckets,options?):TimeBucketCell[]
Defined in: src/core/timeBuckets.ts:302
Aggregate time-stamped quantities into sparse period-table cells { rowId, columnId, value, status, count }, one for every row and bucket, rows in order and buckets in time order. Each item is placed by its instant (time) or interval (start/end, by placement); items outside every bucket are ignored (except to seed carryForward).
Rules, for a loaded bucket with items / without items:
sum: the total / 0.count: the number of items / 0.min,max: the extreme value / null.first,last: the value of the earliest or latest item (by time, or by interval start; ties in input order) / null, or withcarryForwardthe value carried from before.ratio: sum of values divided by sum of denominators, so rates (yield, utilisation) are weighted, never an average of percentages;numeratoranddenominatorare kept on the cell for roll-ups / null. A zero denominator gives null.precomputed: the value of the one item in the bucket, as-is (server-side aggregates) / null. Two items of one row in one bucket throw Error.- a function: see
TimeBucketReducer.
A bucket that loaded does not cover gets status unloaded (or the loading or failed state the function gives) and a null value, so missing data never shows as 0. Throws TypeError for inputs of the wrong type, RangeError for invalid buckets (as createTimeBucketColumns), a non-finite time, value or denominator, an inverted interval or loaded range, an unknown rule, placement or status, a custom result that is neither finite nor null, and more cells than maxCells, and Error for an invalid or duplicate bucket or row ID and a repeated precomputed value. Runs in O((items + cells) · log buckets), plus the overlapped buckets of each interval item.
Type Parameters
T
T = TimeBucketItem
Parameters
items
readonly T[]
buckets
readonly TimeBucket[]
options?
TimeBucketAggregateOptions<T> = {}