public class Tree<T> extends HierarchicalLayout<Tree<T>,T,Tree.Node<T>>
Like most other layouts, the object returned by d3.layout.tree is both an object and a function. That is: you can call the layout like any other function, and the layout has additional methods that change its behavior. Like other classes in D3, layouts follow the method chaining pattern where setter methods return the layout itself, allowing multiple setters to be invoked in a concise statement.
Modifier and Type | Class and Description |
---|---|
static class |
Tree.Node<T>
A node in the tree layout.
|
HierarchicalLayout.Link<T>
Modifier | Constructor and Description |
---|---|
protected |
Tree() |
Modifier and Type | Method and Description |
---|---|
Array<Double> |
nodeSize()
Returns the current node size, which defaults to null, meaning that the
layout has an overall fixed size, which can be retrieved using
size() . |
Tree<T> |
nodeSize(double width,
double height)
Sets a fixed size for each node.
|
Tree<T> |
separation(SeparationFunction<Tree.Node<T>> separation)
Uses the specified function to compute separation between neighboring
nodes.
|
Array<Double> |
size()
Returns the current layout size, which defaults to 1×1.
|
Tree<T> |
size(double width,
double height)
Sets the available layout size.
|
children, links, nodes, sort, sort, toJSOComparator, value, value
public final Tree<T> size(double width, double height)
The size property is exclusive with nodeSize()
: setting size()
sets nodeSize()
to
null.
width
- height
- public final Array<Double> size()
The size property is exclusive with nodeSize()
: setting nodeSize()
sets size()
to
null.
public final Tree<T> nodeSize(double width, double height)
The nodesize property is exclusive with size()
: setting nodeSize()
sets size()
to
null.
width
- height
- public final Array<Double> nodeSize()
size()
.
The nodeSize property is exclusive with size()
: setting size()
sets nodeSize()
to
null.
public final Tree<T> separation(SeparationFunction<Tree.Node<T>> separation)
The separation function is passed two neighboring nodes a and b, and must return the desired separation between nodes. The nodes are typically siblings, though the nodes may also be cousins (or even more distant relations) if the layout decides to place such nodes adjacent.
The default separation function is:
function separation(a, b) {
return a.parent == b.parent ? 1 : 2;
}
A variation that is more appropriate for radial layouts reduces the separation gap proportionally to the radius: *
function separation(a, b) {
return (a.parent == b.parent ? 1 : 2) / a.depth;
}
Copyright © 2017 gwt-d3. All rights reserved.