Visualize.Scale.Linear (Visualize v0.2.25)

Copy Markdown View Source

A continuous linear scale that maps a numeric domain to a numeric range.

Linear scales are the most common scale type, useful for quantitative data.

Summary

Functions

Applies the scale to a value

Returns 0: a linear scale has no bandwidth

Enables or disables clamping

Sets the domain

Inverts the scale

Creates a new linear scale

Extends domain to nice round values

Identity: a linear scale has no padding

Sets the range

Generates tick values

Types

t()

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

Functions

apply(linear, value)

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

Applies the scale to a value

bandwidth(linear)

@spec bandwidth(t()) :: 0

Returns 0: a linear 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(linear, value)

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

Inverts the scale

new()

@spec new() :: t()

Creates a new linear scale

nice(scale)

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

Extends domain to nice round values

padding(scale, padding)

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

Identity: a linear scale has no padding

range(scale, list)

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

Sets the range

ticks(scale, count)

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

Generates tick values