# `Visualize.Shape.Area`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/shape/area.ex#L1)

Area generator for creating filled areas between two lines.

Useful for area charts, stacked areas, and range visualizations.

## Examples

    data = [
      %{date: ~D[2024-01-01], value: 10},
      %{date: ~D[2024-01-02], value: 25},
      %{date: ~D[2024-01-03], value: 15}
    ]

    area = Visualize.Shape.Area.new()
      |> Visualize.Shape.Area.x(fn d -> scale_x.(d.date) end)
      |> Visualize.Shape.Area.y0(fn _d -> height end)  # baseline
      |> Visualize.Shape.Area.y1(fn d -> scale_y.(d.value) end)
      |> Visualize.Shape.Area.curve(:monotone_x)

    path_data = Visualize.Shape.Area.generate(area, data)

# `accessor`

```elixir
@type accessor() :: (any() -&gt; number()) | atom() | number()
```

# `t`

```elixir
@type t() :: %Visualize.Shape.Area{
  curve: Visualize.Shape.Curve.curve_type(),
  curve_opts: keyword(),
  defined: (any() -&gt; boolean()) | nil,
  x: accessor() | nil,
  x0: accessor() | nil,
  x1: accessor() | nil,
  y: accessor() | nil,
  y0: accessor() | nil,
  y1: accessor() | nil
}
```

# `curve`

```elixir
@spec curve(t(), Visualize.Shape.Curve.curve_type(), keyword()) :: t()
```

Sets the curve type

# `defined`

```elixir
@spec defined(t(), (any() -&gt; boolean())) :: t()
```

Sets the defined predicate: a falsy result breaks the area into separate rings

# `generate`

```elixir
@spec generate(t(), Visualize.Data.Table.source()) :: String.t()
```

Generates the SVG path data string.

Note: For backend-agnostic usage, prefer `generate_path/2`
and render with your chosen backend.

# `generate_path`

```elixir
@spec generate_path(t(), Visualize.Data.Table.source()) :: Visualize.IR.Path.t()
```

Generates a Path struct.

Each run of consecutive defined data (see `defined/2`) becomes one closed ring: the top
edge forward, a line to the bottom edge, the bottom edge reversed, and `Z`. A run of
fewer than two points draws nothing.

# `new`

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

Creates a new area generator

# `x0`

```elixir
@spec x0(t(), accessor()) :: t()
```

Sets the x0 accessor (left edge)

# `x1`

```elixir
@spec x1(t(), accessor()) :: t()
```

Sets the x1 accessor (right edge)

# `x`

```elixir
@spec x(t(), accessor()) :: t()
```

Sets the x accessor (used for both x0 and x1)

# `y0`

```elixir
@spec y0(t(), accessor()) :: t()
```

Sets the y0 accessor (bottom edge / baseline)

# `y1`

```elixir
@spec y1(t(), accessor()) :: t()
```

Sets the y1 accessor (top edge)

# `y`

```elixir
@spec y(t(), accessor()) :: t()
```

Sets the y accessor (used for both y0 and y1)

---

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