public class Cluster<T> extends HierarchicalLayout<Cluster<T>,T,Cluster.Node<T>>
For example, a cluster layout can be used to organize software classes in a package hierarchy:
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 |
Cluster.Node<T>
A node in the cluster layout.
|
HierarchicalLayout.Link<T>
Modifier | Constructor and Description |
---|---|
protected |
Cluster() |
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() . |
Cluster<T> |
nodeSize(double width,
double height)
Sets a fixed size for each node.
|
Cluster<T> |
separation(SeparationFunction<Cluster.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.
|
Cluster<T> |
size(double width,
double height)
Sets the available layout size.
|
children, links, nodes, sort, sort, toJSOComparator, value, value
public final Cluster<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 Cluster<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 Cluster<T> separation(SeparationFunction<Cluster.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.