the rows (not changed)
row fields, column fields, values (see PivotConfigIf)
Optional accept: ((sourceIndex) => boolean)a filter: only rows it accepts count (index into rows)
the hierarchies and the values
// case 1: regions × months, sum of umsatz
const result = pivotRows(sales, { rowFields: ["region"], columnFields: ["monat"], values: ["umsatz"] });
result.rowGroups.map(r => `${r.label}: ${result.getValue(r)}`); // ["Nord: 270", "Süd: 180"]
result.getValue(); // 450
// case 3: the average of a column total is the average of its rows
const avg = pivotRows(sales, { rowFields: ["region"], columnFields: ["monat"],
values: [{ value: "umsatz", aggregator: "avg" }] });
const jan = avg.columnLeaves.find(c => c.key === "Jan");
avg.getValue(undefined, jan); // 76.666… (230 / 3) – not 77.5, the mean of 75 and 80
1.1.94
Pivots rows: groups them by the row fields and by the column fields and aggregates the values of every combination, with subtotals and totals – the engine behind PivotFactory (DOM-free, also usable without a table). One pass over the rows; empty combinations are
undefined, averages are computed from sum and count.