A binned scale: a colour or fill scale that cuts its continuous values into bins at its breaks and gives every value in a bin the same colour. Its fields:
range: the range of the finite numbers it has seen, or:nonebefore it has seen any.palette: what gives each bin its colour:{:binned, palette}, a discrete palette ofScales.Palette's, such as{:binned, {:brewer, %{palette: "Blues", direction: -1}}}, its colours for as many levels as there are bins, the first for the lowest; or a continuous palette, such as{:gradient, colors}, or any other ofScales.Palette's, the colour at the middle of each bin's place in the limits.rescaler: how a value's place in the limits is found::rescale, its distance from the low end over the limits' width; or{:mid, midpoint}, its distance from the midpoint over twice the further end's, so the midpoint is at the middle and the further end at 0 or 1.na_value: what a missing value, one not a finite number, or oneoobleaves outside the limits maps to: grey,"#7F7F7F", or:none, no colour.guide: the guide that draws it::colorsteps, a bar of one block of colour for each bin;:legend, a key for each break; or:nonefor none.name: its guide's title,:nonefor none, or:defaultfor the title its mapping gives.limits:{low, high}, the values it spans whatever the data,nilat an end the data decides. A value outside them is handled asoobsays. With neither end given and its breaks the default, the limits are the data's range widened so the end bins are as wide as their neighbours: from the lowest break inside the range less the step to the next, to the highest plus the step from the one before; with one break inside, so it is the middle, from it less its distance to the further end of the range to it plus the same; with none inside, not widened, its ends its breaks, and a range of one value widened by 0.05 either side first.oob: what happens to a value outside the limits before it is binned, as a continuous scale'soobsays::squish, a finite number moved onto the nearer limit, so it takes the colour of the bin at that end; any other ofGiggly.Scale.Continuous's; a value still outside, or missing, maps tona_value.breaks: the values its bins are cut at, beside the limits: a list, those inside the limits kept, in the order given; a function handed the limits,{low, high}, and for one of two arguments[n: n_breaks]too, that returns them, or{value, label}pairs, a pair's label the break's unlesslabelssays otherwise, kept as a list's are, the limits not widened;:nonefor one bin; or:defaultfor aboutn_breaks, chosen asnice_breakssays on the limits, those at either end of the data's range left out where the limits are widened.n_breaks: how many default breaks are wanted, or a breaks function of two arguments is asked for, 5 unless given; nice breaks may number a few more or fewer.nice_breaks:truefor default breaks chosen to be round numbers, as a continuous scale's are,n_breaksof them wanted, 2 or more;falseforn_breaksbreaks spaced evenly between the ends of the limits, 1 or more.labels: a label for each break: a list, one for each of its given breaks, or of its default ones, a break left out taking its label with it,nilfor a missing one; a function handed every break kept, that returns their labels, each a string, a power (Scales.Labels.log/2) ornil;:nonefor none; or:default, each written as a continuous scale writes a number.right: where a value on a break falls:truein the bin below it,falsein the bin above; the lowest value is in the lowest bin, and the highest in the highest.show_limits:trueto have colour steps label the ends of the bar with the limits, written by itslabelsas its breaks are, unless a break is already there;falsefor the breaks alone. A legend shows the breaks alone either way.
Summary
Types
@type t() :: %Giggly.Scale.Binned{ breaks: :default | :none | [number()] | ({float(), float()} -> list()) | ({float(), float()}, keyword() -> list()), guide: :colorsteps | :legend | :none, labels: :default | :none | [String.t() | nil] | ([float()] -> [Scales.Labels.power_label()]), limits: {number() | nil, number() | nil}, n_breaks: pos_integer(), na_value: String.t() | :none, name: :default | :none | String.t(), nice_breaks: boolean(), oob: Giggly.Scale.Continuous.oob(), palette: {:binned, Scales.Palette.t()} | Scales.Palette.t(), range: :none | {number(), number()}, rescaler: :rescale | {:mid, number()}, right: boolean(), show_limits: boolean() }