A continuous scale. Giggly.Plot.scale_x_continuous/2, Giggly.Plot.scale_x_date/2,
Giggly.Plot.scale_x_datetime/2 and Giggly.Plot.scale_x_time/2 record one with the options
they are given and no range, and Giggly.panel_scales/2 returns an axis's trained. Its fields:
range: the range of the finite numbers it has seen, or:nonebefore it has seen any.transform: the transformation its values are put through before it sees them, so its range is in transformed space::identityfor numbers;:datefor dates, which it sees as days since 1970-01-01;{:datetime, zone, database}for date-times, which it sees as seconds since 1970-01-01 00:00 UTC, a naive one as though its clock were UTC's,zonebeing the time zone its breaks are laid and written in,:defaultuntil its first column gives it one, or:naivefor naive date-times, anddatabasetheCalendar.TimeZoneDatabasethat reads it;:timefor times of day, which it sees as seconds since midnight; or any other transformation of numbersScales.Transformnames,:log10,:reverse(each value negated), a composition or one of a user's own among them, as a plot's scale names one, on an axis or on any other aesthetic.palette: what turns a value's place in its limits into its aesthetic's value::identityfor a position, left for the coordinate system to place;{:rescale, {low, high}}for an aesthetic such as alpha or line width, each place, from 0 to 1, rescaled ontolowtohigh; and{:gradient, colors}for colour and fill, the colour that far along a gradient throughcolors, spaced evenly, blended in Lab*, or{:gradient, colors, values}, spaced atvalues; and for size,{:area, {low, high}}, each place's square root rescaled ontolowtohigh, so a value's area grows with it, or{:abs_area, max}, the square root of the place's size rescaled onto 0 tomax; or any other ofScales.Palette's, such as{:brewer, %{palette: "Blues", direction: 1}}, a discrete one taken as a gradient through its colours; or:as_is, an identity scale's, each value handed back as it stands, unscaled, asGiggly.Plot.scale_size_identity/2and its kin record it; or{:theme, fallback}, a scale given no palette, asGiggly.Plot.scale_color_continuous/2records it, andGiggly.Plot.scale_alpha_continuous/2and its kin given norange:, which takes the theme's palette for its aesthetic (Giggly.Plot.theme/2'spalette_color_continuous:and the rest), or elsefallback, the function's own, when the plot is run.rescaler: how a value's place in the limits is found::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance from the midpoint, in transformed space, over twice the further end's, so the midpoint is at the middle and the further end at 0 or 1;:max, the value over the high end, so 0 is at 0; or a function of the values and the limits, both in transformed space, that returns a place for each, asGiggly.Plot.scale_color_gradient/2and its kin recordrescaler:.na_value: what a value the palette gives nothing for maps to, a missing one, oneoobleaves missing, or for a colour one left outside the limits or infinite, while an alpha, size or line width is an infinity for an infinite value:nilfor a position, alpha, line width and size, grey,"#7F7F7F", for colour and fill, or:none, no colour.guide: the guide that draws it: for a position:default, the axis its coordinate system draws for it, unless a scale function chooses:axis, an axis beside the panel, or an axis{:axis, options}makes (%Giggly.Guide.Axis{});:legendfor alpha, line width, size and:colorbarfor colour and fill unless a scale function chooses:legend,:colorstepsor:bins, a key for each bin between its breaks, or a legend{:legend, options}makes (%Giggly.Guide.Legend{});:nonefor none.aesthetics: the aesthetics other than position it serves, in the order it trains on them, asGiggly.Plot'saesthetics:option names them: one scale trained once over every one of them, each drawing its own guide; its own aesthetic alone by default, and:nonefor a position.position: the side of the panels a position's axis goes on,:bottomor:topfor x,:leftor:rightfor y, or:nonefor the coordinate system's own, below and left; an aesthetic other than position reads none.secondary: a position's secondary axis, drawn opposite its axis (Giggly.Scale.Secondary), or:nonefor none; an aesthetic other than position reads 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, in data units,nilat an end the data decides; once transformed, the two are sorted. Or a function, handed the trained range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits in data units, kept in the order returned, so a high end first leaves every value outside them. A value outside them is handled asoobsays.oob: what happens to a value outside the limits, in transformed space, before it is placed, and for a position again once the stat and position have moved it::censor, a finite number outside made missing, so a position's row is not drawn and another aesthetic's value takesna_value;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept, a position drawn past the panel's edge and a colour takingna_value, as its palette gives none there, while an opacity or a size runs on past its range; or a function handed one column's values and the limits,{low, high}, that returns a value for each, a number,:infinity,:neg_infinity,nilor:nan, R's NaN, which is missing.breaksandminor_breaks: the values an axis marks, in data units; on a date axis,{:width, [week: 1]}for a break every step, one of:day,:week,:monthand:yearand how many of it, on a date-time axis:second,:minuteand:hourtoo, and on a time axis:second,:minuteand:houralone; a function, handed the limits,{low, high}in data units, a date axis's rounded out to whole days, and for breaks of two arguments[n: n_breaks]too, or[]wheren_breaksis the default, and for minor breaks of two arguments the breaks drawn, that returns the values, or{value, label}pairs, a pair's label the break's unlesslabelssays otherwise;:nonefor none; or:defaultfor those its transformation chooses.n_breaks: how many breaks its transformation, or a breaks function of two arguments, is asked for, or:defaultfor as many as it chooses.labels: a label for each break, a string or a label another library lays out (Giggly.Label),nilfor a missing one; a function handed every break drawn, in data units, a time axis's as times of day wrapped past midnight, that returns their labels, each a string, a power (Scales.Labels.log/2), a label another library lays out ornil; on a date, date-time or time axis,{:format, format}, each break written informatbyCalendar.strftime/3, a time's wrapped past midnight;:nonefor none; or:defaultfor its transformation's.expand: how far an axis reaches beyond its limits,[mult: {low, high}, add: {low, high}]: at each end, that multiple of the limits' width plus that constant.
Summary
Types
A date, date-time or time axis's step between breaks: one unit and how many of it,
[week: 1], a date-time's or a time's [hour: 6].
What a scale does with a value outside its limits: one of R's oob_* functions by name, or a
function of one column's values and the limits that returns a value for each.
How a scale places a value between its limits, from 0 to 1: R's rescale(), rescale_mid() or
rescale_max() by name, or a function of one column's values and the limits that returns a
place for each.
A value a date, date-time or time axis places.
Types
@type date_step() :: [ {:second | :minute | :hour | :day | :week | :month | :year, pos_integer()} ]
A date, date-time or time axis's step between breaks: one unit and how many of it,
[week: 1], a date-time's or a time's [hour: 6].
@type oob() :: :censor | :censor_any | :squish | :squish_any | :squish_infinite | :keep | (list(), {number(), number()} -> list())
What a scale does with a value outside its limits: one of R's oob_* functions by name, or a
function of one column's values and the limits that returns a value for each.
How a scale places a value between its limits, from 0 to 1: R's rescale(), rescale_mid() or
rescale_max() by name, or a function of one column's values and the limits that returns a
place for each.
@type t() :: %Giggly.Scale.Continuous{ aesthetics: :none | [atom()], breaks: :default | :none | [number() | time_value()] | {:width, date_step()} | ({term(), term()} -> list()) | ({term(), term()}, keyword() -> list()), expand: [mult: {number(), number()}, add: {number(), number()}], guide: :default | :axis | :legend | :colorbar | :colorsteps | :bins | :none | struct(), labels: :default | :none | [String.t() | nil] | ([number() | time_value()] -> [Scales.Labels.power_label()]) | {:format, String.t()}, limits: {number() | time_value() | nil, number() | time_value() | nil} | ({term(), term()} -> {term(), term()}), minor_breaks: :default | :none | [number() | time_value()] | {:width, date_step()} | ({term(), term()} -> list()) | ({term(), term()}, list() -> list()), n_breaks: :default | pos_integer(), na_value: nil | number() | String.t() | :none, name: :default | :none | String.t(), oob: oob(), palette: Scales.Palette.t() | :as_is | {:theme, Scales.Palette.t()}, position: :none | :bottom | :top | :left | :right, range: :none | {number(), number()}, rescaler: rescaler(), secondary: :none | Giggly.Scale.Secondary.t(), transform: Scales.Transform.name() }
@type time_value() :: Date.t() | DateTime.t() | NaiveDateTime.t() | Time.t()
A value a date, date-time or time axis places.