Cluster layout algorithm for dendrogram visualizations.
Similar to the tree layout, but all leaves are placed at the same depth, creating a dendrogram effect useful for hierarchical clustering visualizations.
Examples
data = %{
name: "root",
children: [
%{name: "A", children: [%{name: "A1"}, %{name: "A2"}]},
%{name: "B", children: [%{name: "B1"}, %{name: "B2"}, %{name: "B3"}]}
]
}
root = Visualize.Layout.Hierarchy.new(data)
cluster = Visualize.Layout.Cluster.new()
|> Visualize.Layout.Cluster.size([400, 200])
positioned = Visualize.Layout.Cluster.generate(cluster, root)
Summary
Functions
Generates the cluster layout, positioning all nodes.
Creates a new cluster layout
Sets the fixed node size.
Sets the separation function between nodes.
Sets the size of the layout.
Types
@type t() :: %Visualize.Layout.Cluster{ node_size: {number(), number()} | nil, separation: (Visualize.Layout.Hierarchy.t(), Visualize.Layout.Hierarchy.t() -> number()) | nil, size: {number(), number()} | nil }
Functions
@spec generate(t(), Visualize.Layout.Hierarchy.t()) :: Visualize.Layout.Hierarchy.t()
Generates the cluster layout, positioning all nodes.
Unlike tree layout, all leaves are placed at the same y coordinate.
@spec new() :: t()
Creates a new cluster layout
Sets the fixed node size.
Unlike size/2, this sets a fixed spacing between nodes.
@spec separation(t(), (Visualize.Layout.Hierarchy.t(), Visualize.Layout.Hierarchy.t() -> number())) :: t()
Sets the separation function between nodes.
The function receives two leaf nodes and returns the desired separation.
Sets the size of the layout.
The cluster will be scaled to fit within [width, height].