Options
All
  • Public
  • Public/Protected
  • All
Menu

Pivot

Index

Type Aliases

Cube<TSource>: TSource[][][]

A cube is a three dimensional data structure.

Type Parameters

  • TSource

Dimension<TSource>: Predicate<TSource>[]

A dimension is a series of predicates used to partition data.

Type Parameters

  • TSource

Matrix<TSource>: TSource[][]

A matrix is a two dimensional data structure.

Type Parameters

  • TSource

Functions

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

    Type Parameters

    • TSource

    Parameters

    • selector: Function<TSource, number>

      A callback function to derive a numerical value for each object in the source data.

    Returns Function<TSource[], number>

  • criteria<TSource>(key: keyof TSource): Function<TSource[keyof TSource], Predicate<TSource>>
  • Create a callback to used in a map operation to create the predicate for each point on a dimension from a set of simple values.

    Type Parameters

    • TSource

    Parameters

    • key: keyof TSource

      The property in the source data to base this predicate on.

    Returns Function<TSource[keyof TSource], Predicate<TSource>>

  • Pivots source data by one or more dimensions returning an n-cube.

    Type Parameters

    • TSource

    Parameters

    • source: TSource[]

      The source data, an array of objects.

    • first: Dimension<TSource>

      The first dimension to pivot the source data by.

    • Rest ...additional: Dimension<TSource>[]

      0-n additional dimensions to pivot the source data by.

    Returns Matrix<any>

    Returns an n-cube; minimally a Matrix if only one dimension passed, a Cube if two dimensions passed, and so one as more dimensions added.

  • map<TSource, TResult>(cube: Cube<TSource>, query: Callback<TSource[], TResult>): Matrix<TResult>
  • Queries data from a cube.

    Type Parameters

    • TSource

    • TResult

    Parameters

    • cube: Cube<TSource>

      The cube to query data from.

    • query: Callback<TSource[], TResult>

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

    Returns Matrix<TResult>

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

    Type Parameters

    • TSource

    Parameters

    • selector: Function<TSource, number>

      A callback function to derive a numerical value for each object in the source data.

    Returns Function<TSource[], number>

Generated using TypeDoc