Visualize.Layout.Partition (Visualize v0.2.35)

Copy Markdown View Source

Partition layout for adjacency diagrams.

Creates icicle diagrams (rectangular) or sunburst diagrams (radial) where the area of each node is proportional to its value.

Unlike treemaps which show leaf nodes, partition layouts show the full hierarchy with each level getting equal vertical/radial space.

Examples

data = %{
  name: "root",
  children: [
    %{name: "A", value: 100},
    %{name: "B", children: [
      %{name: "B1", value: 50},
      %{name: "B2", value: 75}
    ]}
  ]
}

root = Visualize.Layout.Hierarchy.new(data)
  |> Visualize.Layout.Hierarchy.sum(fn d -> d[:value] || 0 end)

# Rectangular partition (icicle diagram)
partition = Visualize.Layout.Partition.new()
  |> Visualize.Layout.Partition.size([400, 300])

positioned = Visualize.Layout.Partition.generate(partition, root)
# Each node has x0, y0, x1, y1

# Radial partition (sunburst)
partition = Visualize.Layout.Partition.new()
  |> Visualize.Layout.Partition.size([2 * :math.pi(), 200])

positioned = Visualize.Layout.Partition.generate(partition, root)
# x0/x1 are angles, y0/y1 are radii

Summary

Functions

Generates the partition layout

Creates a new partition layout

Sets padding between siblings

Enables rounding coordinates to integers

Sets the size of the partition layout.

Types

t()

@type t() :: %Visualize.Layout.Partition{
  padding: number(),
  round?: boolean(),
  size: {number(), number()}
}

Functions

generate(partition, root)

Generates the partition layout

new()

@spec new() :: t()

Creates a new partition layout

padding(partition, p)

@spec padding(t(), number()) :: t()

Sets padding between siblings

round(partition, round?)

@spec round(t(), boolean()) :: t()

Enables rounding coordinates to integers

size(partition, arg2)

@spec size(t(), [number()] | {number(), number()}) :: t()

Sets the size of the partition layout.

For rectangular layouts: [width, height] For radial layouts (sunburst): [angle_extent, radius]