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)
Summary
Functions
Sets the sector-centre accessor (for roses), in the scale's domain units
Creates a new arc generator
Creates a new area generator
Creates a new band (state timeline) generator
Sets the corner radius (for arcs)
Sets the curve interpolation type
Sets the defined predicate
Sets the end angle (for arcs and pies)
Sets the fill accessor (for bands and x-bands)
Generates output from a shape generator.
Generates a Path struct (for Line, Area, Arc, Symbol, Band), a map of them for PercentileBand, or a list of them for Rose.
Sets the height accessor (for bands)
Sets the inner {lo, hi} band (for percentile bands); nil clears it
Sets the inner radius (for arcs and roses)
Sets the keys for stack generator
Sets the label accessor (for rules and x-bands); nil clears it
Creates a new line generator
Sets the median accessor (for percentile bands); nil clears it
Creates a new needle generator (spec/04 §16)
Sets the offset for stack generator
Sets the order for stack generator
Sets the outer {lo, hi} band (for percentile bands); nil clears it
Sets the outer radius (for arcs and roses)
Sets the pad angle (for arcs, pies and roses)
Sets the pad radius (for arcs)
Creates a new percentile-band generator (spec/04 §14)
Creates a new pie layout generator
Creates a new rose generator (spec/04 §15)
Creates a new rule (vertical annotation) generator
Sets the x scale (for rules and x-bands); nil means pixel values
Sets the symbol size
Sets the data comparator (for pies); nil clears it
Sets the value comparator (for pies); nil clears it
Creates a new stack generator
Sets the start angle (for arcs and pies)
Creates a new symbol generator
Sets the symbol type
Sets the value accessor (for pie and stack)
Sets the sector-width accessor (for roses), in the scale's domain units
Sets the x0 accessor (for areas, bands and x-bands)
Sets the x1 accessor (for areas, bands and x-bands)
Sets the x accessor
Creates a new x-band (shaded interval annotation) generator
Sets the y0 accessor (baseline for areas; extent for rules and x-bands)
Sets the y1 accessor (for areas; extent for rules and x-bands)
Sets the y accessor
Functions
Sets the sector-centre accessor (for roses), in the scale's domain units
Creates a new arc generator
Creates a new area generator
Creates a new band (state timeline) generator
Sets the corner radius (for arcs)
Sets the curve interpolation type
Sets the defined predicate
Sets the end angle (for arcs and pies)
Sets the fill accessor (for bands and x-bands)
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
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.
Sets the height accessor (for bands)
Sets the inner {lo, hi} band (for percentile bands); nil clears it
Sets the inner radius (for arcs and roses)
Sets the keys for stack generator
Sets the label accessor (for rules and x-bands); nil clears it
Creates a new line generator
Sets the median accessor (for percentile bands); nil clears it
Creates a new needle generator (spec/04 §16)
Sets the offset for stack generator
Sets the order for stack generator
Sets the outer {lo, hi} band (for percentile bands); nil clears it
Sets the outer radius (for arcs and roses)
Sets the pad angle (for arcs, pies and roses)
Sets the pad radius (for arcs)
Creates a new percentile-band generator (spec/04 §14)
Creates a new pie layout generator
Creates a new rose generator (spec/04 §15)
Creates a new rule (vertical annotation) generator
Sets the x scale (for rules and x-bands); nil means pixel values
Sets the symbol size
Sets the data comparator (for pies); nil clears it
Sets the value comparator (for pies); nil clears it
Creates a new stack generator
Sets the start angle (for arcs and pies)
Creates a new symbol generator
Sets the symbol type
Sets the value accessor (for pie and stack)
Sets the sector-width accessor (for roses), in the scale's domain units
Sets the x0 accessor (for areas, bands and x-bands)
Sets the x1 accessor (for areas, bands and x-bands)
Sets the x accessor
Creates a new x-band (shaded interval annotation) generator
Sets the y0 accessor (baseline for areas; extent for rules and x-bands)
Sets the y1 accessor (for areas; extent for rules and x-bands)
Sets the y accessor