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

Shape generators for creating SVG paths from data.

Provides generators for common chart elements:
- Lines and areas for time series
- Arcs for pie and donut charts
- Symbols for scatter plots
- Stacks for stacked bar/area charts
- Bands (state timelines), rules and x-bands (annotations) as element lists
- Percentile bands (median plus inner and outer bands) as a map of paths
- Roses (one arc sector per datum over a radial scale) as a list of paths

## Examples

    # Line chart
    line = Visualize.Shape.line()
      |> Visualize.Shape.x(fn d -> scale_x.(d.date) end)
      |> Visualize.Shape.y(fn d -> scale_y.(d.value) end)
      |> Visualize.Shape.curve(:monotone_x)

    path_data = Visualize.Shape.generate(line, data)

    # Pie chart
    pie = Visualize.Shape.pie()
      |> Visualize.Shape.value(:count)

    arcs = Visualize.Shape.generate(pie, data)

    # Stacked area chart
    stack = Visualize.Shape.stack()
      |> Visualize.Shape.keys([:apples, :oranges, :bananas])

    series = Visualize.Shape.generate(stack, data)

# `angle`

Sets the sector-center accessor (for roses), in the scale's domain units

# `arc`

Creates a new arc generator

# `area`

Creates a new area generator

# `band`

Creates a new band (state timeline) generator

# `corner_radius`

Sets the corner radius (for arcs)

# `curve`

Sets the curve interpolation type

# `defined`

Sets the defined predicate

# `end_angle`

Sets the end angle (for arcs and pies)

# `fill`

Sets the fill accessor (for bands and x-bands)

# `generate`

Generates output from a shape generator.

For Line, Area, Arc: returns path data string
For Pie: returns list of arc data maps
For Symbol: returns path data string
For Stack: returns list of series with stacked values
For Band, Rule, XBand: returns a list of `Visualize.IR.Element`
For PercentileBand: returns `%{outer:, inner:, median:}` of path strings
For Rose: returns a list of path strings, one per datum

# `generate_path`

Generates a Path struct (for Line, Area, Arc, Symbol, Band), a map of them for
PercentileBand, or a list of them for Rose.

Use this for backend-agnostic path generation, then render
with `Visualize.Render.to_string/2` or create an element with
`Visualize.IR.Element.path/2`.

# `height`

Sets the height accessor (for bands)

# `inner`

Sets the inner `{lo, hi}` band (for percentile bands); `nil` clears it

# `inner_radius`

Sets the inner radius (for arcs and roses)

# `keys`

Sets the keys for stack generator

# `label`

Sets the label accessor (for rules and x-bands); `nil` clears it

# `line`

Creates a new line generator

# `median`

Sets the median accessor (for percentile bands); `nil` clears it

# `needle`

Creates a new needle generator (spec/04 §16)

# `offset`

Sets the offset for stack generator

# `order`

Sets the order for stack generator

# `outer`

Sets the outer `{lo, hi}` band (for percentile bands); `nil` clears it

# `outer_radius`

Sets the outer radius (for arcs and roses)

# `pad_angle`

Sets the pad angle (for arcs, pies and roses)

# `pad_radius`

Sets the pad radius (for arcs)

# `percentile_band`

Creates a new percentile-band generator (spec/04 §14)

# `pie`

Creates a new pie layout generator

# `rose`

Creates a new rose generator (spec/04 §15)

# `rule`

Creates a new rule (vertical annotation) generator

# `scale`

Sets the x scale (for rules and x-bands); `nil` means pixel values

# `size`

Sets the symbol size

# `sort`

Sets the data comparator (for pies); `nil` clears it

# `sort_values`

Sets the value comparator (for pies); `nil` clears it

# `stack`

Creates a new stack generator

# `start_angle`

Sets the start angle (for arcs and pies)

# `symbol`

Creates a new symbol generator

# `type`

Sets the symbol type

# `value`

Sets the value accessor (for pie and stack)

# `width`

Sets the sector-width accessor (for roses), in the scale's domain units

# `x0`

Sets the x0 accessor (for areas, bands and x-bands)

# `x1`

Sets the x1 accessor (for areas, bands and x-bands)

# `x`

Sets the x accessor

# `x_band`

Creates a new x-band (shaded interval annotation) generator

# `y0`

Sets the y0 accessor (baseline for areas; extent for rules and x-bands)

# `y1`

Sets the y1 accessor (for areas; extent for rules and x-bands)

# `y`

Sets the y accessor

---

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