Visualize.Scale.Ordinal (Visualize v0.2.35)

Copy Markdown View Source

A discrete scale that maps categorical values to a discrete range.

Useful for encoding categorical data with colors or shapes.

Summary

Functions

Applies the scale to a categorical value

Returns 0: an ordinal scale has no bandwidth

Identity: an ordinal scale never extrapolates

Sets the domain (list of categories)

Not applicable for ordinal scales

Creates a new ordinal scale

Returns the scale unchanged

Identity: an ordinal scale has no padding

Sets the range (list of output values)

Returns the domain values as ticks

Sets the value to return for unknown domain values

Types

t()

@type t() :: %Visualize.Scale.Ordinal{domain: [any()], range: [any()], unknown: any()}

Functions

apply(ordinal, value)

@spec apply(t(), any()) :: any()

Applies the scale to a categorical value

bandwidth(ordinal)

@spec bandwidth(t()) :: 0

Returns 0: an ordinal scale has no bandwidth

clamp(scale, clamp?)

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

Identity: an ordinal scale never extrapolates

domain(scale, categories)

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

Sets the domain (list of categories)

invert(ordinal, value)

@spec invert(t(), any()) :: nil

Not applicable for ordinal scales

new()

@spec new() :: t()

Creates a new ordinal scale

nice(scale)

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

Returns the scale unchanged

padding(scale, padding)

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

Identity: an ordinal scale has no padding

range(scale, values)

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

Sets the range (list of output values)

ticks(ordinal, count)

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

Returns the domain values as ticks

unknown(scale, value)

@spec unknown(t(), any()) :: t()

Sets the value to return for unknown domain values