A discrete scale, a category to a range element (spec/06 §9).
apply/2 finds the first domain element equal (==) to the value, else the first of
the same spelling (Macaw.Base.Names.same?/2: :ok and "ok" are one category), and
answers the range element at its index, the range cycling when the domain is longer. A
value the domain lacks answers unknown, nil by default; the domain is never extended
implicitly.
The lookup is a map built once by domain/2: each category's first index keyed by the
category (an integral float keyed as its integer, as == equates them), and a second
keyed by its spelling, so apply/2 costs two map reads at most whatever the domain's
length. inspect/1 leaves the derived maps out.
Summary
Functions
The range element of a category, the range cycling; unknown for a category the domain
lacks or an empty range.
0: an ordinal scale has no bandwidth.
Identity: an ordinal scale never extrapolates.
Sets the domain, a list of any terms; answers the struct.
nil: an ordinal scale is not invertible.
An ordinal scale with no domain and no range.
Identity.
Identity: an ordinal scale has no padding.
Sets the range, a list; answers the struct.
The domain; the count is ignored.
Sets the value for a category the domain lacks (default nil); answers the struct.
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
@type t() :: %Macaw.Draw.Scale.Ordinal{ domain: [term()], index: %{optional(term()) => non_neg_integer()}, range: [term()], spelled: %{optional(term()) => non_neg_integer()}, unknown: term(), values: tuple() }
Functions
The range element of a category, the range cycling; unknown for a category the domain
lacks or an empty range.
0: an ordinal scale has no bandwidth.
Identity: an ordinal scale never extrapolates.
Sets the domain, a list of any terms; answers the struct.
nil: an ordinal scale is not invertible.
@spec new() :: t()
An ordinal scale with no domain and no range.
Identity.
Identity: an ordinal scale has no padding.
Sets the range, a list; answers the struct.
The domain; the count is ignored.
Sets the value for a category the domain lacks (default nil); answers the struct.