Interface PivotValueIf<T>

One value of a pivot table in full form: where the value of a row comes from, how it is aggregated, and how its columns are named. The short form is just the ValueAccessor ("umsatz" = the sum of umsatz).

Example

const revenue: PivotValueIf<Order> = { value: "total", label: "Revenue" };                  // sum
const orders: PivotValueIf<Order> = { value: "id", aggregator: "count", label: "Orders" };
const avgPrice: PivotValueIf<Order> = {
value: o => o.total / o.quantity, aggregator: "avg", label: "Avg. price",
format: v => v === undefined ? "" : `${(v as number).toFixed(2)} €`
};

Since

1.1.94

Type Parameters

  • T = any

    the row type

Hierarchy

  • PivotValueIf

Properties

aggregator?: AggregatorRef

A built-in aggregator by name ("sum", "avg", "count" …) or an own AggregatorIf. Default "sum".

format?: ((result) => string)

Type declaration

    • (result): string
    • The text of a result in a cell. Default: numbers with at most two decimals ("1,234.5"). Excel gets the raw value.

      Parameters

      • result: unknown

      Returns string

label?: string

The header of its columns (with several values). Default: the name. Text only – never HTML.

name?: string

The id of the value – part of the column properties and the name in PivotResult.getValue. Default: "<aggregator>(<path>)", e.g. "sum(umsatz)"; for a function "<aggregator>(value<N>)".

showValuesAs?: ShowValuesAsConfig

„Show values as“ (since 1.1.95): "percentOfRowTotal" (each pivot row = 100 %), "percentOfColumnTotal", "percentOfGrandTotal" or "percentOfParentTotal" (share of the parent row group). The cells then hold the fraction (Excel: number with percent format), the text is a percentage; format is not used. Other modes of ShowValuesAs don't apply to a pivot (the value is shown).

Example

values: [{ value: "umsatz", showValuesAs: "percentOfRowTotal" }]
value: ValueAccessor<T>

The value of a row: a property path ("umsatz", "order.total") or a function.