Visualize.Scale.Radial (Visualize v0.2.35)

Copy Markdown View Source

An angle scale: a cyclic domain — bearing, hour of day, day of year — to radians (spec/03 §14, D-30).

The mapping is Visualize.Scale.Linear's with a range in radians, one full turn by default; angles follow Visualize.Shape.Arc's convention, clockwise from 12 o'clock, so a bearing domain [0, 360] needs no offset. ticks/2 returns count equal divisions of the domain — exact, not the nice-step sequence — and nice/1 is identity: the domain of a cyclic quantity is its period.

bearing = Visualize.Scale.radial() |> Visualize.Scale.domain([0, 360])
Visualize.Scale.apply(bearing, 90)      # => π/2
Visualize.Scale.ticks(bearing, 4)       # => [0.0, 90.0, 180.0, 270.0]

Summary

Functions

Maps a domain value to radians

Returns 0: a radial scale has no bandwidth

Enables or disables clamping

Sets the domain

Maps radians back to the domain; never clamps

Creates a radial scale: domain [0, 1], range [0, 2π]

Identity: the domain of a cyclic quantity is its period

Identity: a radial scale has no padding

Sets the range, in radians

Returns count equal divisions of the domain from d0.

Types

t()

@type t() :: %Visualize.Scale.Radial{
  clamp?: boolean(),
  domain: [number()],
  range: [number()]
}

Functions

apply(scale, value)

@spec apply(t(), number()) :: float()

Maps a domain value to radians

bandwidth(radial)

@spec bandwidth(t()) :: 0

Returns 0: a radial scale has no bandwidth

clamp(scale, clamp?)

@spec clamp(t(), boolean()) :: t()

Enables or disables clamping

domain(scale, list)

@spec domain(t(), [number()]) :: t()

Sets the domain

invert(scale, value)

@spec invert(t(), number()) :: float()

Maps radians back to the domain; never clamps

new()

@spec new() :: t()

Creates a radial scale: domain [0, 1], range [0, 2π]

nice(scale)

@spec nice(t()) :: t()

Identity: the domain of a cyclic quantity is its period

padding(scale, padding)

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

Identity: a radial scale has no padding

range(scale, list)

@spec range(t(), [number()]) :: t()

Sets the range, in radians

ticks(radial, count)

@spec ticks(t(), integer()) :: [float()]

Returns count equal divisions of the domain from d0.

The last division, d1, is dropped when the range is a full turn — it coincides with the first on the circle — and kept otherwise. count <= 0 yields [].