By using the summary reducer, you have the flexibility of computing all kind of summaries based on the available data.
We introduced the concept of
- which are simple objects with the following props:
initialValue - the initial value to be used for the summary computation - generally a number/string/etc
reducer(accumulator, currentItem) - the reducer function - basically computes the summary from the accumulated value (at first call, this will equal the
initialValue) and the current item at which we are doing the computation
complete(accumulatedValue, array) - can be used for doing one last computation at the end of the iteration - for example useful for computing the average of a value. The first argument is the accumulated value, while the second is the array on which the summary was computed against
In the snippet below, we display
average values for the population column.
The example above shows the summaries for the population in one cell - see the demo below to display multiple footer rows, one for each summary type.