Aggregate

Represents the PivotGrid aggregate object. Applicable for local data binding.

const sumAggregate: Aggregate = {
    init: (data) => { data.sum = ('sum' in data) ? data.sum : 0; },
    accumulate: (data, value) => { data.sum += value; },
    merge: (src, dest) => { dest.sum += src.sum; },
    result: data => data.sum,
    format: (value: number) => value.toFixed(2)
};
NameTypeDefaultDescription

accumulate

(data: any, value: any) => void

The accumulate function will be called for every value that needs to be aggregated.

format

(value: any) => string

The format function will be called when the value returned from the result function needs to be formatted.

init

(data: any) => void

The init function initializes the variable where the aggregated data will be stored and returns it in the passed data object. The init function will be called every time before calling accumulate and merge functions.

merge

(src: any, dest: any) => void

The merge function will be called when two aggregated data objects needs to be merged into one.

result

(data: any) => any

The result function will be called when the aggregated value needs to be extracted from the data object.

In this article

Not finding the help you need?