A discrete scale dividing a numeric range into uniform bands, one per category (spec/06 §10): what a bar chart places its bars by.
The band math is d3-scale's rescale: a descending range lays the bands out in reverse
with a positive step and bandwidth, and round/2 floors the step and rounds the
start and bandwidth so every position is a whole number. Every setter lays the bands out
again and keeps the layout and each category's slot in the struct, so apply/2,
bandwidth/1 and step/1 cost the same over a thousand categories as over ten.
inspect/1 leaves the derived slots and layout out; a struct built by hand rather
than by the setters has no slots and places nothing.
Summary
Functions
Sets how the outer space is shared, 0 ≤ a ≤ 1, 0.5 centering the bands:
{:ok, scale} or {:error, [{[], {:range, :align, a}}]}.
align/2, answering the scale or raising Macaw.Draw.Error.
The start of a category's band, or nil for a value not in the domain.
The width of each band.
Identity: a band scale never extrapolates.
Sets the categories, any list; answers the struct.
nil: a band scale is not invertible.
A band scale with no categories over [0, 1].
Identity.
Sets the inner and outer padding together, 0 ≤ p < 1: {:ok, scale}, or
{:error, [{[], {:range, :padding, p}}]}.
padding/2, answering the scale or raising Macaw.Draw.Error.
Sets the padding between bands, 0 ≤ p < 1: {:ok, scale} or {:error, faults}.
padding_inner/2, answering the scale or raising Macaw.Draw.Error.
Sets the padding at the range's ends, p ≥ 0: {:ok, scale} or {:error, faults}.
padding_outer/2, answering the scale or raising Macaw.Draw.Error.
Sets the range, two numbers: {:ok, scale} or {:error, faults}.
range/2, answering the scale or raising Macaw.Draw.Error.
Sets rounding: the step floored, the start and bandwidth rounded; answers the struct.
The distance between adjacent band starts; floored when the scale rounds.
The domain; the count is ignored.
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
Sets how the outer space is shared, 0 ≤ a ≤ 1, 0.5 centering the bands:
{:ok, scale} or {:error, [{[], {:range, :align, a}}]}.
align/2, answering the scale or raising Macaw.Draw.Error.
The start of a category's band, or nil for a value not in the domain.
The width of each band.
Identity: a band scale never extrapolates.
Sets the categories, any list; answers the struct.
nil: a band scale is not invertible.
@spec new() :: t()
A band scale with no categories over [0, 1].
Identity.
Sets the inner and outer padding together, 0 ≤ p < 1: {:ok, scale}, or
{:error, [{[], {:range, :padding, p}}]}.
padding/2, answering the scale or raising Macaw.Draw.Error.
Sets the padding between bands, 0 ≤ p < 1: {:ok, scale} or {:error, faults}.
padding_inner/2, answering the scale or raising Macaw.Draw.Error.
Sets the padding at the range's ends, p ≥ 0: {:ok, scale} or {:error, faults}.
padding_outer/2, answering the scale or raising Macaw.Draw.Error.
Sets the range, two numbers: {:ok, scale} or {:error, faults}.
range/2, answering the scale or raising Macaw.Draw.Error.
Sets rounding: the step floored, the start and bandwidth rounded; answers the struct.
The distance between adjacent band starts; floored when the scale rounds.
The domain; the count is ignored.