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

A continuous symmetric-log scale, for data spanning orders of magnitude through zero
(spec/06 §7).

The transform is `S(x) = sign(x) · ln(1 + |x| / c)`, inverse
`S⁻¹(y) = sign(y) · c · (e^|y| − 1)`, `c` the constant, above 0: linear near zero and
logarithmic beyond `c`. Its ticks are the signed decades of the constant and zero, its
`nice/1` is `Macaw.Draw.Scale.Linear`'s, and when it clamps it clamps its output to the
range's bounds.

# `error`

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

A refusal: faults with their paths.

# `t`

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

# `apply`

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

The range value of `value` through the transform, `0.5` of the range when the
transformed domain collapses, clamped to the range's bounds when the scale clamps; `nil`
for a value that is not a number.

# `bandwidth`

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

`0`: a symlog scale has no bandwidth.

# `clamp`

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

Sets clamping of the output to the range; answers the struct.

# `constant`

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

Sets the transition constant, a number above 0: `{:ok, scale}`, or
`{:error, [{[], {:not_positive, c}}]}`.

# `constant!`

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

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

# `domain`

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

Sets the domain, a two-element list or tuple of numbers, stored as a list.

# `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, `S⁻¹(S(d0) + t · (S(d1) − S(d0)))`; never clamps.

# `new`

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

The default scale: domain `[-1, 1]`, range `[0, 1]`, constant 1.

# `nice`

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

`Macaw.Draw.Scale.Linear.nice/1`'s domain.

# `padding`

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

Identity: a symlog scale has no padding.

# `range`

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

Sets the range, a two-element list or tuple of numbers, stored as a list.

# `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()
```

The signed decades of the constant and zero inside the domain, ascending: `−c · 10^k`
below zero, `0` when the domain holds it, `c · 10^k` above, each side strided to about
`count` values (spec/06 §7.2). A domain holding no decade answers `[]`.

---

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