A discretizing scale by uniform buckets: the domain divided into as many equal segments as the range has elements (spec/06 §12).
scale = Macaw.Draw.Scale.Quantize.new() |> Macaw.Draw.Scale.Quantize.domain!([0, 100])
scale = Macaw.Draw.Scale.Quantize.range(scale, [:low, :mid, :high, :top])
Macaw.Draw.Scale.Quantize.apply(scale, 60)
#=> :highapply/2 always clamps: a value outside the domain maps to the first or last element.
Summary
Functions
The range element of the value's bucket, min(⌊t · n⌋, n − 1) for t its clamped
position in the domain (0 in a collapsed one); nil for an empty range or a value
that is no number.
0: a quantize scale has no bandwidth.
The number of buckets, the range's length.
Identity: a quantize scale always clamps.
Sets the domain, two numbers as a list or a tuple, stored as a list.
domain/2, answering the scale or raising Macaw.Draw.Error.
nil: a quantize scale maps many values to one bucket.
The sub-interval of the domain a range element stands for,
{d0 + k·step, d0 + (k+1)·step}; nil for an empty range or an element not in it.
A quantize scale over [0, 1] with no range.
Identity.
Identity: a quantize scale has no padding.
Sets the range, a list; answers the struct.
The n − 1 interior boundaries; [] for fewer than two range elements.
thresholds/1; the count is ignored.
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
The range element of the value's bucket, min(⌊t · n⌋, n − 1) for t its clamped
position in the domain (0 in a collapsed one); nil for an empty range or a value
that is no number.
0: a quantize scale has no bandwidth.
@spec bucket_count(t()) :: non_neg_integer() | error()
The number of buckets, the range's length.
Identity: a quantize scale always clamps.
Sets the domain, two numbers as a list or a tuple, stored as a list.
domain/2, answering the scale or raising Macaw.Draw.Error.
nil: a quantize scale maps many values to one bucket.
The sub-interval of the domain a range element stands for,
{d0 + k·step, d0 + (k+1)·step}; nil for an empty range or an element not in it.
@spec new() :: t()
A quantize scale over [0, 1] with no range.
Identity.
Identity: a quantize scale has no padding.
Sets the range, a list; answers the struct.
The n − 1 interior boundaries; [] for fewer than two range elements.
thresholds/1; the count is ignored.