Options
All
  • Public
  • Public/Protected
  • All
Menu

Pivot

Index

Type Aliases

Criteria<TRow>: Criterion<TRow>[]

The set of criterion used to select items for a row or column within a cube.

Type Parameters

  • TRow extends Row

Cube<TValue>: TValue[][][]

A cube of data.

Type Parameters

  • TValue

Dimension<TRow>: Criteria<TRow>[]

An dimension to pivot a table by; this is a set of criteria for the dimension.

Type Parameters

  • TRow extends Row

Key: string | number

The type of keys supported.

Row: { [ key in Key]: any }

The type of rows supported.

Functions

  • average<TRow>(selector: Callback<TRow, number>): Callback<TRow[], number>
  • A generator, to create a function to pass into query that averages numerical values derived from rows in a cube.

    Type Parameters

    • TRow extends Row

    Parameters

    • selector: Callback<TRow, number>

      A callback function to derive a numerical value for each row.

    Returns Callback<TRow[], number>

    Returns a callback function that can be passed into the map function returning the average of the values for a cell or NaN if there are no values in that cell.

  • cube<TRow>(table: TRow[], axes: Axes<TRow>): Cube<TRow>
  • Pivots a table by two axes

    Type Parameters

    • TRow extends Row

    Parameters

    • table: TRow[]

      The source data, an array of rows.

    • axes: Axes<TRow>

      The dimensions to use for the x and y axes.

    Returns Cube<TRow>

    Returns an cube, being the source table split by the criteria of the dimensions used for the x and y axes.

  • Creates a dimension from an array of values.

    Type Parameters

    • TRow extends Row

    Parameters

    • values: any[]

      A distinct list of values for the dimension.

    • key: Key

      The name to give this dimension.

    • criteria: Callback<any, Criteria<TRow>> = ...

      An optional callback to build the dimensions criteria.

    Returns Dimension<TRow>

    Returns a simple dimension with a single criterion for each key/value combination.

  • distinct<TRow>(table: TRow[], key: Key, getValue?: Callback<TRow, any>): any[]
  • Returns a distinct list of values for a column of a table.

    Type Parameters

    • TRow extends Row

    Parameters

    • table: TRow[]

      The source data, a table of rows.

    • key: Key

      The column name to find the distinct values for.

    • getValue: Callback<TRow, any> = ...

      An optional callback to derive values from the source data.

    Returns any[]

    Returns the distinct set of values for the key

  • filter<TRow>(predicate: Callback<TRow, boolean>): Callback<TRow[], TRow[]>
  • A generator, used to filter data within a cube.

    Type Parameters

    • TRow extends Row

    Parameters

    • predicate: Callback<TRow, boolean>

      A predicate to test a row of data to see if it should be included in the filter results.

    Returns Callback<TRow[], TRow[]>

  • map<TRow, TResult>(cube: Cube<TRow>, selector: Callback<TRow[], TResult>): TResult[][]
  • Queries data from a cube, or any matrix structure.

    Type Parameters

    • TRow

    • TResult

    Parameters

    • cube: Cube<TRow>

      The source data.

    • selector: Callback<TRow[], TResult>

      A callback function to create a result from each cell of the cube.

    Returns TResult[][]

  • select<TRow, TResult>(selector: Callback<TRow, TResult>): Callback<TRow[], TResult[]>
  • A generator, used to transform the source data in a cube to another representation.

    Type Parameters

    • TRow

    • TResult

    Parameters

    • selector: Callback<TRow, TResult>

      A function to transform a source record into the desired result.

    Returns Callback<TRow[], TResult[]>

  • slice<TRow>(dimension: Dimension<TRow>): Function<TRow[], TRow[][]>
  • Generates a function to slice data by the criteria specified in a dimension.

    Type Parameters

    • TRow extends Row

    Parameters

    • dimension: Dimension<TRow>

      The dimension to generate the slicer for.

    Returns Function<TRow[], TRow[][]>

    Returns a function that will take a table and slice it into an array of tables each conforming to the criteria of a point on a dimension.

  • sum<TRow>(selector: Callback<TRow, number>): Callback<TRow[], number>
  • A generator, to create a function to pass into query that sums numerical values derived from rows in a cube.

    Type Parameters

    • TRow extends Row

    Parameters

    • selector: Callback<TRow, number>

      A callback function to derive a numerical value for each row.

    Returns Callback<TRow[], number>

Generated using TypeDoc