Visualize.Shape.Rose (Visualize v0.2.25)

Copy Markdown View Source

Rose generator: one Visualize.Shape.Arc sector per datum, centred on its angle and as long as its value (spec/04 §15, D-31).

angle/2 and width/2 are in the domain units of the radial scale given to scale/2 (radians without one); the radii are pixels. Each datum's path is exactly the Arc call with the same numbers, so a stacked wind rose is several roses with rising inner radii.

Examples

bearing = Visualize.Scale.radial() |> Visualize.Scale.domain([0, 360])
radius = Visualize.Scale.sqrt() |> Visualize.Scale.domain([0, 40]) |> Visualize.Scale.range([0, 120])

rose =
  Visualize.Shape.Rose.new()
  |> Visualize.Shape.Rose.scale(bearing)
  |> Visualize.Shape.Rose.angle(:bearing)
  |> Visualize.Shape.Rose.width(45)
  |> Visualize.Shape.Rose.outer_radius(fn d -> Visualize.Scale.apply(radius, d.count) end)
  |> Visualize.Shape.Rose.pad_angle(0.02)

paths = Visualize.Shape.Rose.generate(rose, bins)

Summary

Functions

Sets the sector-centre accessor, in the scale's domain units

Returns one SVG path-data string per datum

Returns one IR.Path per datum: the Arc sector centred on its angle

Sets the inner radius accessor, in pixels

Creates a rose generator reading tuple elements 0 and 1 as angle and outer radius

Sets the outer radius accessor, in pixels

Sets the pad angle accessor, radians, as Visualize.Shape.Arc.pad_angle/2

Sets the radial scale the angles map through; nil means radians

Sets the sector-width accessor, in the scale's domain units

Types

accessor()

@type accessor() :: Visualize.Shape.Line.accessor()

t()

@type t() :: %Visualize.Shape.Rose{
  angle: accessor() | nil,
  inner_radius: accessor(),
  outer_radius: accessor() | nil,
  pad_angle: accessor(),
  scale: struct() | nil,
  width: accessor()
}

Functions

angle(rose, accessor)

@spec angle(t(), accessor()) :: t()

Sets the sector-centre accessor, in the scale's domain units

generate(rose, data)

@spec generate(t(), Visualize.Data.Table.source()) :: [String.t()]

Returns one SVG path-data string per datum

generate_path(rose, data)

@spec generate_path(t(), Visualize.Data.Table.source()) :: [Visualize.IR.Path.t()]

Returns one IR.Path per datum: the Arc sector centred on its angle

inner_radius(rose, accessor)

@spec inner_radius(t(), accessor()) :: t()

Sets the inner radius accessor, in pixels

new()

@spec new() :: t()

Creates a rose generator reading tuple elements 0 and 1 as angle and outer radius

outer_radius(rose, accessor)

@spec outer_radius(t(), accessor()) :: t()

Sets the outer radius accessor, in pixels

pad_angle(rose, accessor)

@spec pad_angle(t(), accessor()) :: t()

Sets the pad angle accessor, radians, as Visualize.Shape.Arc.pad_angle/2

scale(rose, scale)

@spec scale(t(), struct() | nil) :: t()

Sets the radial scale the angles map through; nil means radians

width(rose, accessor)

@spec width(t(), accessor()) :: t()

Sets the sector-width accessor, in the scale's domain units