# `Visualize.Format.Auto`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/format/auto.ex#L1)

Tick formats derived from what a realized scale already knows: its domain and the tick
count (spec/05 §3.1, D-134).

A time domain is formatted by its span and the interval its ticks use — clock times
within a day, days within a week, dates within a season, months beyond — and a numeric
one by its magnitude — plain below 1,000, grouped from 1,000, one SI prefix from a
million. The declarative layer's axis uses these wherever a design gives no `format`
(spec/14 §4.4).

Every function takes `locale:`, `"en"` by default and the only locale that ships; any
other raises `ArgumentError`.

## Examples

    iex> Visualize.Format.Auto.notation([0, 90_000])
    :grouped

    iex> Visualize.Format.Auto.number({:si, 6}).(2_500_000)
    "2.5M"

    iex> Visualize.Format.Auto.time_format([~U[2024-03-01 00:00:00Z], ~U[2024-03-01 02:00:00Z]])
    "%H:%M"

# `notation`

```elixir
@type notation() :: :plain | :grouped | {:si, 6..24} | :si
```

How a numeric domain's ticks are written: by magnitude, or `:si` per value.

# `time`

```elixir
@type time() :: DateTime.t() | NaiveDateTime.t() | Date.t()
```

A time value a time scale's domain holds.

# `formatter`

```elixir
@spec formatter(struct(), keyword()) :: (term() -&gt; String.t()) | nil
```

The derived formatter of a realized scale, or `nil` when the default label serves (a
band, ordinal or discretizing scale).

## Options

- `:count` - the tick count the axis asks for (default `10`), which chooses a time
  scale's interval
- `:locale` - default `"en"`

# `notation`

```elixir
@spec notation([number()], keyword()) :: :plain | :grouped | {:si, 6..24}
```

The notation a numeric domain's magnitude — its greatest `|d|` — calls for: `:plain`
below 1,000, `:grouped` below a million, else `{:si, e}` with `e` the exponent of the
largest SI prefix not above it (spec/05 §3.1).

## Options

- `:locale` - default `"en"`

# `number`

```elixir
@spec number(notation(), keyword()) :: (term() -&gt; String.t())
```

The formatter of a notation (spec/05 §3.1): `:plain` the default label, `:grouped` it
grouped in threes, `{:si, e}` every value over `10ᵉ` with that prefix (zero stays `0`),
`:si` each value with its own prefix from `k` up. A non-number is `to_string/1`.

## Options

- `:locale` - default `"en"`

# `time_format`

```elixir
@spec time_format([time()], keyword()) :: String.t()
```

The `Visualize.Format.time/2` specifier for a time domain: by its span, and by whether
the interval `count` ticks use over it is under a day (spec/05 §3.1).

## Options

- `:count` - the tick count (default `10`)
- `:locale` - default `"en"`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
