# `Visualize.Layout.Treemap`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/layout/treemap.ex#L1)

Treemap layout for hierarchical data as nested rectangles.

Treemaps display hierarchical data as a set of nested rectangles,
where the area of each rectangle is proportional to its value.

## Examples

    data = %{
      name: "root",
      children: [
        %{name: "A", value: 100},
        %{name: "B", value: 200},
        %{name: "C", children: [
          %{name: "C1", value: 50},
          %{name: "C2", value: 75}
        ]}
      ]
    }

    # Build hierarchy and compute values
    root = Visualize.Layout.Hierarchy.new(data)
      |> Visualize.Layout.Hierarchy.sum(fn d -> d[:value] || 0 end)

    # Apply treemap layout
    treemap = Visualize.Layout.Treemap.new()
      |> Visualize.Layout.Treemap.size([400, 300])
      |> Visualize.Layout.Treemap.padding(2)

    positioned = Visualize.Layout.Treemap.generate(treemap, root)

    # Each node now has x0, y0, x1, y1 coordinates

## Tiling Algorithms

- `:squarify` - Squarified treemap (default, good aspect ratios)
- `:binary` - Binary split (recursive halving)
- `:slice` - Horizontal slices
- `:dice` - Vertical slices
- `:slice_dice` - Alternating slice/dice by depth

# `t`

```elixir
@type t() :: %Visualize.Layout.Treemap{
  padding: number(),
  padding_bottom: number() | nil,
  padding_inner: number() | nil,
  padding_left: number() | nil,
  padding_right: number() | nil,
  padding_top: number() | nil,
  round?: boolean(),
  size: {number(), number()},
  tile: tile_algorithm()
}
```

# `tile_algorithm`

```elixir
@type tile_algorithm() :: :squarify | :binary | :slice | :dice | :slice_dice
```

# `generate`

```elixir
@spec generate(t(), Visualize.Layout.Hierarchy.t()) :: Visualize.Layout.Hierarchy.t()
```

Generates the treemap layout

# `new`

```elixir
@spec new() :: t()
```

Creates a new treemap layout

# `padding`

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

Sets uniform padding on all sides

# `padding_bottom`

```elixir
@spec padding_bottom(t(), number()) :: t()
```

Sets the bottom padding

# `padding_inner`

```elixir
@spec padding_inner(t(), number()) :: t()
```

Sets the inner padding between siblings

# `padding_left`

```elixir
@spec padding_left(t(), number()) :: t()
```

Sets the left padding

# `padding_right`

```elixir
@spec padding_right(t(), number()) :: t()
```

Sets the right padding

# `padding_top`

```elixir
@spec padding_top(t(), number()) :: t()
```

Sets the top padding

# `round`

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

Enables rounding of coordinates to integers

# `size`

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

Sets the size of the treemap

# `tile`

```elixir
@spec tile(t(), tile_algorithm()) :: t()
```

Sets the tiling algorithm

---

*Consult [api-reference.md](api-reference.md) for complete listing*
