Interface HierarchyRectangularNode<Datum>

interface HierarchyRectangularNode {
    new HierarchyRectangularNodenew (data): HierarchyRectangularNode<Datum>;
    children?: HierarchyRectangularNode<Datum>[];
    data: Datum;
    depth: number;
    height: number;
    id?: string;
    parent: HierarchyRectangularNode<Datum>;
    value?: number;
    x?: number;
    x0: number;
    x1: number;
    y?: number;
    y0: number;
    y1: number;
    [iterator](): Iterator<HierarchyRectangularNode<Datum>, any, undefined>;
    ancestors(): HierarchyRectangularNode<Datum>[];
    copy(): HierarchyRectangularNode<Datum>;
    count(): HierarchyRectangularNode<Datum>;
    descendants(): HierarchyRectangularNode<Datum>[];
    each<T>(func, that?): HierarchyRectangularNode<Datum>;
    eachAfter<T>(func, that?): HierarchyRectangularNode<Datum>;
    eachBefore<T>(func, that?): HierarchyRectangularNode<Datum>;
    find(filter): HierarchyRectangularNode<Datum>;
    leaves(): HierarchyRectangularNode<Datum>[];
    links(): HierarchyRectangularLink<Datum>[];
    path(target): HierarchyRectangularNode<Datum>[];
    sort(compare): HierarchyRectangularNode<Datum>;
    sum(value): HierarchyRectangularNode<Datum>;
}

Type Parameters

  • Datum

Hierarchy

Constructors

Methods

  • Return a deep copy of the subtree starting at this node. The returned deep copy shares the same data, however. The returned node is the root of a new tree; the returned node’s parent is always null and its depth is always zero.

    Returns HierarchyRectangularNode<Datum>

  • Invokes the specified function for node and each descendant in breadth-first order, such that a given node is only visited if all nodes of lesser depth have already been visited, as well as all preceding nodes of the same depth.

    Type Parameters

    • T = undefined

    Parameters

    • func: ((this, node, index, thisNode) => void)

      The specified function is passed the current descendant, the zero-based traversal index, and this node.

    • Optional that: T

      If that is specified, it is the this context of the callback.

    Returns HierarchyRectangularNode<Datum>

  • Invokes the specified function for node and each descendant in post-order traversal, such that a given node is only visited after all of its descendants have already been visited.

    Type Parameters

    • T = undefined

    Parameters

    • func: ((this, node, index, thisNode) => void)

      The specified function is passed the current descendant, the zero-based traversal index, and this node.

    • Optional that: T

      If that is specified, it is the this context of the callback.

    Returns HierarchyRectangularNode<Datum>

  • Invokes the specified function for node and each descendant in pre-order traversal, such that a given node is only visited after all of its ancestors have already been visited.

    Type Parameters

    • T = undefined

    Parameters

    • func: ((this, node, index, thisNode) => void)

      The specified function is passed the current descendant, the zero-based traversal index, and this node.

    • Optional that: T

      If that is specified, it is the this context of the callback.

    Returns HierarchyRectangularNode<Datum>

  • Sorts the children of this node, if any, and each of this node’s descendants’ children, in pre-order traversal using the specified compare function, and returns this node.

    Parameters

    • compare: ((a, b) => number)

      The compare function is passed two nodes a and b to compare. If a should be before b, the function must return a value less than zero; if b should be before a, the function must return a value greater than zero; otherwise, the relative order of a and b are not specified. See array.sort for more.

    Returns HierarchyRectangularNode<Datum>

  • Evaluates the specified value function for this node and each descendant in post-order traversal, and returns this node. The node.value property of each node is set to the numeric value returned by the specified function plus the combined value of all descendants.

    Parameters

    • value: ((d) => number)

      The value function is passed the node’s data, and must return a non-negative number.

        • (d): number
        • Parameters

          • d: Datum

          Returns number

    Returns HierarchyRectangularNode<Datum>

Properties

children?: HierarchyRectangularNode<Datum>[]

An array of child nodes, if any; undefined for leaf nodes.

data: Datum

The associated data, as specified to the constructor.

depth: number

Zero for the root node, and increasing by one for each descendant generation.

height: number

Zero for leaf nodes, and the greatest distance from any descendant leaf for internal nodes.

id?: string

Optional node id string set by StratifyOperator, if hierarchical data was created from tabular data using stratify().

The parent node, or null for the root node.

value?: number

Aggregated numeric value as calculated by sum(value) or count(), if previously invoked.

x?: number

The x position of this node. Set after a tree has been laid out by tree or cluster.

const root = d3.hierarchy(datum);
const treeLayout = d3.tree();
treeLayout(root);
// x and y are now set on root and its descendants
x0: number

The left edge of the rectangle.

x1: number

The right edge of the rectangle.

y?: number

The y position of this node. Set after a tree has been laid out by tree or cluster.

const root = d3.hierarchy(datum);
const treeLayout = d3.tree();
treeLayout(root);
// x and y are now set on root and its descendants
y0: number

The top edge of the rectangle

y1: number

The bottom edge of the rectangle.