# `Macaw.Draw.Scale.Log`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/scale/log.ex#L1)

A continuous logarithmic scale, for data spanning orders of magnitude (spec/06 §5).

Every logarithm is `log(x) / log(base)`, exact for bases 10 and 2. The domain's bounds
must be positive: one at or below zero is the fault `{[i], {:not_positive, value}}`. A
value at or below zero has no position on a log axis and applies to `nil`, as does a
value that is not a number. `ticks/2` are d3-scale's log ticks.

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `t`

```elixir
@type t() :: %Macaw.Draw.Scale.Log{
  base: number(),
  clamp?: boolean(),
  domain: [number()],
  range: [number()]
}
```

# `apply`

```elixir
@spec apply(t(), term()) :: float() | nil | error()
```

The range value of a positive `value`, by `t = (log v − log d0) / (log d1 − log d0)`,
clamped to `[0, 1]` when the scale clamps; `nil` for a value at or below zero or not a
number.

# `bandwidth`

```elixir
@spec bandwidth(t()) :: 0 | error()
```

`0`: a log scale has no bandwidth.

# `clamp`

```elixir
@spec clamp(t(), boolean()) :: t() | error()
```

Sets clamping; answers the struct.

# `domain`

```elixir
@spec domain(t(), term()) :: {:ok, t()} | error()
```

Sets the domain, both bounds positive: `{:ok, scale}` or `{:error, faults}`.

# `domain!`

```elixir
@spec domain!(t(), term()) :: t()
```

`domain/2`, answering the scale or raising `Macaw.Draw.Error`.

# `invert`

```elixir
@spec invert(t(), term()) :: float() | nil | error()
```

The domain value of a range value, `base ^ (log d0 + t · (log d1 − log d0))`; never clamps.

# `new`

```elixir
@spec new() :: t()
```

The default scale, base 10.

# `new`

```elixir
@spec new(term()) :: {:ok, t()} | error()
```

A log scale of `base`, a number above 0 and not 1: `{:ok, scale}`, or
`{:error, [{[], {:log_base, base}}]}`.

# `new!`

```elixir
@spec new!(term()) :: t()
```

`new/1`, answering the scale or raising `Macaw.Draw.Error`.

# `nice`

```elixir
@spec nice(t()) :: t() | error()
```

The domain extended to integer powers of the base.

# `padding`

```elixir
@spec padding(t(), number()) :: t() | error()
```

Identity: a log scale has no padding.

# `range`

```elixir
@spec range(t(), term()) :: {:ok, t()} | error()
```

Sets the range, two numbers: `{:ok, scale}` or `{:error, faults}`.

# `range!`

```elixir
@spec range!(t(), term()) :: t()
```

`range/2`, answering the scale or raising `Macaw.Draw.Error`.

# `ticks`

```elixir
@spec ticks(t(), number()) :: [number()] | error()
```

About `count` ticks, as d3-scale's log ticks are (spec/06 §5.2).

Within fewer decades than the count and with an integer base, every `k · base^e`
(`1 ≤ k < base`) inside the domain, falling back to `Macaw.Draw.Ticks.ticks/3` over the
domain when those number under half the count; otherwise the exponents thinned by the
tick rule at the real count `min(j − i, count)` and mapped back through the base. A
count at or below zero is read as 1.

---

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