Interface TreeLayout<Datum>

interface TreeLayout {
    nodeSize(): [number, number];
    nodeSize(size): TreeLayout<Datum>;
    separation(): ((a, b) => number);
    separation(separation): TreeLayout<Datum>;
    size(): [number, number];
    size(size): TreeLayout<Datum>;
    (root): HierarchyPointNode<Datum>;
}

Type Parameters

  • Datum

  • Lays out the specified root hierarchy. You may want to call root.sort before passing the hierarchy to the tree layout.

    Parameters

    Returns HierarchyPointNode<Datum>

Methods

  • Returns the current node size, which defaults to null. A node size of null indicates that a layout size will be used instead.

    Returns [number, number]

  • Sets this tree layout’s node size to the specified [width, height] array and returns this tree layout. When a node size is specified, the root node is always positioned at <0, 0>.

    Parameters

    • size: [number, number]

      The specified two-element size array.

    Returns TreeLayout<Datum>

  • Returns the current separation accessor, which defaults to: (a, b) => a.parent == b.parent ? 1 : 2.

    Returns ((a, b) => number)

      • (a, b): number
      • Returns the current separation accessor, which defaults to: (a, b) => a.parent == b.parent ? 1 : 2.

        Parameters

        Returns number

  • Sets the separation accessor to the specified function and returns this tree layout. The separation accessor is used to separate neighboring nodes.

    Parameters

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

      The separation function is passed two nodes a and b, and must return the desired separation. The nodes are typically siblings, though the nodes may be more distantly related if the layout decides to place such nodes adjacent.

    Returns TreeLayout<Datum>

  • Returns the current layout size, which defaults to [1, 1]. A layout size of null indicates that a node size will be used instead.

    Returns [number, number]

  • Sets this tree layout’s size to the specified [width, height] array and returns the tree layout. The size represent an arbitrary coordinate system; for example, to produce a radial layout, a size of [360, radius] corresponds to a breadth of 360° and a depth of radius.

    Parameters

    • size: [number, number]

      The specified two-element size array.

    Returns TreeLayout<Datum>