Interface StratifyOperator<Datum>

interface StratifyOperator {
    id(): ((d, i, data) => string);
    id(id): StratifyOperator<Datum>;
    parentId(): ((d, i, data) => string);
    parentId(parentId): StratifyOperator<Datum>;
    path(): ((d, i, data) => string);
    path(path): StratifyOperator<Datum>;
    (data): HierarchyNode<Datum>;
}

Type Parameters

  • Datum

  • Generates a new hierarchy from the specified tabular data. Each node in the returned object has a shallow copy of the properties from the corresponding data object, excluding the following reserved properties: id, parentId, children.

    Parameters

    • data: Datum[]

      The root specified data.

    Returns HierarchyNode<Datum>

    Throws

    Error on missing id, ambiguous id, cycle, multiple roots or no root.

Methods

Methods

  • Returns the current id accessor, which defaults to: (d) => d.id.

    Returns ((d, i, data) => string)

      • (d, i, data): string
      • Returns the current id accessor, which defaults to: (d) => d.id.

        Parameters

        • d: Datum
        • i: number
        • data: Datum[]

        Returns string

  • Sets the id accessor to the given function. The id accessor is invoked for each element in the input data passed to the stratify operator. The returned string is then used to identify the node's relationships in conjunction with the parent id. For leaf nodes, the id may be undefined, null or the empty string; otherwise, the id must be unique.

    Parameters

    • id: ((d, i, data) => string)

      The id accessor.

        • (d, i, data): string
        • Parameters

          • d: Datum
          • i: number
          • data: Datum[]

          Returns string

    Returns StratifyOperator<Datum>

  • Returns the current parent id accessor, which defaults to: (d) => d.parentId.

    Returns ((d, i, data) => string)

      • (d, i, data): string
      • Returns the current parent id accessor, which defaults to: (d) => d.parentId.

        Parameters

        • d: Datum
        • i: number
        • data: Datum[]

        Returns string

  • Sets the parent id accessor to the given function. The parent id accessor is invoked for each element in the input data passed to the stratify operator. The returned string is then used to identify the node's relationships in conjunction with the id. For the root node, the parent id should be undefined, null or the empty string. There must be exactly one root node in the input data, and no circular relationships.

    Parameters

    • parentId: ((d, i, data) => string)

      The parent id accessor.

        • (d, i, data): string
        • Parameters

          • d: Datum
          • i: number
          • data: Datum[]

          Returns string

    Returns StratifyOperator<Datum>

  • Returns the current path accessor, which defaults to undefined.

    Returns ((d, i, data) => string)

      • (d, i, data): string
      • Parameters

        • d: Datum
        • i: number
        • data: Datum[]

        Returns string

  • If path is specified, sets the path accessor to the given function and returns this stratify operator. Otherwise, returns the current path accessor, which defaults to undefined. If a path accessor is set, the id and parentId arguments are ignored, and a unix-like hierarchy is computed on the slash-delimited strings returned by the path accessor, imputing parent nodes and ids as necessary.

    Parameters

    • path: ((d, i, data) => string)

      The path accessor.

        • (d, i, data): string
        • Parameters

          • d: Datum
          • i: number
          • data: Datum[]

          Returns string

    Returns StratifyOperator<Datum>