The rules of a chart's scales that the server and the browser both apply: nice domains, the ticks of a number axis and of a time axis, the bins of a histogram and the units of a time.
They are written twice, here and in assets/src/rules.ts, word for
word: a change here is a change there. One fixture,
test/fixtures/rules.json, holds the cases that both test suites run.
Times are milliseconds since 1970 in UTC.
Summary
Functions
The bin of a value among the bins {start, step, n}: from 0 to n - 1.
The bins of the numbers from min to max, about count of them, at
round numbers: {start, step, n}, the first bin [start, start + step)
and the last one closed, so that max is in it.
The start of a time's unit: :minute, :hour, :day, :week (from
Monday), :month, :quarter or :year.
The step between ticks of about count ticks from start to stop: a
positive number, or, for a step under 1, minus its inverse (-10 is a
step of 0.1), which keeps it exact.
The domain from start to stop widened to round numbers, so that its
ends are ticks of about count ticks. A domain of one value widens
around it.
The time step units after a time at the start of its unit.
About count ticks between start and stop, at round numbers, in order.
About count ticks of a time axis from start to stop, at the starts
of round units: {unit, step, ticks}, where the unit says how to write
them (:month: "Mar").
Functions
@spec bin({number(), number(), pos_integer()}, number()) :: non_neg_integer()
The bin of a value among the bins {start, step, n}: from 0 to n - 1.
@spec bins(number(), number(), pos_integer()) :: {number(), number(), pos_integer()}
The bins of the numbers from min to max, about count of them, at
round numbers: {start, step, n}, the first bin [start, start + step)
and the last one closed, so that max is in it.
The start of a time's unit: :minute, :hour, :day, :week (from
Monday), :month, :quarter or :year.
The step between ticks of about count ticks from start to stop: a
positive number, or, for a step under 1, minus its inverse (-10 is a
step of 0.1), which keeps it exact.
The domain from start to stop widened to round numbers, so that its
ends are ticks of about count ticks. A domain of one value widens
around it.
The time step units after a time at the start of its unit.
About count ticks between start and stop, at round numbers, in order.
About count ticks of a time axis from start to stop, at the starts
of round units: {unit, step, ticks}, where the unit says how to write
them (:month: "Mar").