A continuous power scale: d3's signed power, sqrt its exponent 0.5 (spec/06 §6).
The transform is T(x) = sign(x) · |x|^e, applied to the domain's bounds and the value
alike, so a domain that includes negatives maps symmetrically and invert/2 answers
negative domain values. ticks/2 and nice/1 are Macaw.Draw.Scale.Linear's over the
domain: linear in the domain, not in the transformed space. When it clamps, the scale
clamps its output to the range's bounds.
scale = Macaw.Draw.Scale.Power.sqrt() |> Macaw.Draw.Scale.Power.domain!([0, 100])
Macaw.Draw.Scale.Power.apply(Macaw.Draw.Scale.Power.range!(scale, [0, 10]), 25)
#=> 5.0
Summary
Functions
The range value of value by the signed power, 0.5 of the range in a collapsed
transformed domain, clamped to the range's bounds when the scale clamps; nil for a
value that is not a number.
0: a power scale has no bandwidth.
Sets clamping of the output to the range; answers the struct.
Sets the domain, a two-element list or tuple of numbers, stored as a list.
domain/2, answering the scale or raising Macaw.Draw.Error.
Sets the exponent, a number; answers the struct.
The domain value of a range value, T⁻¹(T(d0) + t · (T(d1) − T(d0))); never clamps.
A power scale of exponent 1.
Macaw.Draw.Scale.Linear.nice/1's domain.
Identity: a power scale has no padding.
Sets the range, a two-element list or tuple of numbers, stored as a list.
range/2, answering the scale or raising Macaw.Draw.Error.
A square-root scale: exponent 0.5, kind :sqrt.
Macaw.Draw.Scale.Linear.ticks/2 over the domain.
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
Functions
The range value of value by the signed power, 0.5 of the range in a collapsed
transformed domain, clamped to the range's bounds when the scale clamps; nil for a
value that is not a number.
0: a power scale has no bandwidth.
Sets clamping of the output to the range; answers the struct.
Sets the domain, a two-element list or tuple of numbers, stored as a list.
domain/2, answering the scale or raising Macaw.Draw.Error.
Sets the exponent, a number; answers the struct.
The domain value of a range value, T⁻¹(T(d0) + t · (T(d1) − T(d0))); never clamps.
@spec new() :: t()
A power scale of exponent 1.
Macaw.Draw.Scale.Linear.nice/1's domain.
Identity: a power scale has no padding.
Sets the range, a two-element list or tuple of numbers, stored as a list.
range/2, answering the scale or raising Macaw.Draw.Error.
@spec sqrt() :: t()
A square-root scale: exponent 0.5, kind :sqrt.
Macaw.Draw.Scale.Linear.ticks/2 over the domain.