Bland.Ticks (Elixir Technical Drawing v0.3.0)

Copy Markdown View Source

Nice-rounded tick generation.

Picks evenly-spaced tick values within a domain using the classic 1-2-2.5-5-10 decade decomposition so that axes break on numbers a human would pick by hand — the kind of axis you'd draw on engineering graph paper.

iex> Bland.Ticks.nice({0.0, 9.7}, 5) |> Enum.take(3)
[0.0, 2.0, 4.0]

Summary

Functions

Default tick formatter: trims trailing zeros from floats and renders integers without a decimal point.

Log-axis ticks at integer powers of base that fall within the domain.

Produces a list of tick values for a linear axis. target is the approximate number of ticks desired; the returned list will be close to that count but pinned to nice, round step sizes.

Functions

format(v)

@spec format(number()) :: String.t()

Default tick formatter: trims trailing zeros from floats and renders integers without a decimal point.

log_nice(arg, base \\ 10)

@spec log_nice(
  {number(), number()},
  number()
) :: [float()]

Log-axis ticks at integer powers of base that fall within the domain.

nice(arg, target \\ 6)

@spec nice(
  {number(), number()},
  pos_integer()
) :: [float()]

Produces a list of tick values for a linear axis. target is the approximate number of ticks desired; the returned list will be close to that count but pinned to nice, round step sizes.