# `Macaw.Frame.Furniture`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/furniture.ex#L1)

The grid and the axes a model places (spec/03 §3, §3.1, §3.2), and the order a frame's
groups draw in.

- **The order** (§3, `compose/3`): the grid, the layers (a layer kind declaring
  `order: :beneath` first), the axes, the legend, the labels, the same in every model.
  Grid and axes groups are `aria-hidden`; a frame's clip reaches its layers alone.
- **The grid** (§3.1): `grid: true` on an axis draws a line at each of its ticks across
  the plot, in one group `class="mw-grid"` behind every layer, in the `grid` style.
- **Axes** (§3.2, `axis/3`): `Macaw.Draw.Axis` over the realized scale, oriented by its
  `side`, placed by the model (cartesian: `bottom` at `translate(0, h)`, `right` at
  `translate(w, 0)`); the derived tick count is the axis's length at 80 pixels a tick
  across and 35 down, clamped to `2..10`; the derived format follows the scale; a
  `measure` (the axis's own, else its bound field's `unit` and `quantity` from the
  slot's schema, spec/02 §4.4) scales the ticks into the display unit under the
  viewer's system, and an
  axis whose ticks cannot carry the unit draws the measure's title unless a label
  anchors there. The group is `class="mw-axis mw-axis-<side>"`.

Furniture is drawn into `Macaw.Draw.IR` elements. Copied from visualize's
`Visualize.Chart.Frame.Furniture`, colors as theme roles.

The options every function here takes: `:theme`, `:mode` (`:css` or `:literal`),
`:styles` (the design's styles), `:labels` (the frame's labels), `:schemas` (each
slot's schema, for declared names and measures) and `:bindings` (the cell's binding of
each slot's roles to fields).

# `parts`

```elixir
@type parts() :: %{
  grid: [Macaw.Draw.IR.Element.t()],
  axes: [Macaw.Draw.IR.Element.t()],
  outer: [Macaw.Draw.IR.Element.t()],
  legend: [Macaw.Draw.IR.Element.t()],
  labels: [Macaw.Draw.IR.Element.t()],
  origin: {number(), number()}
}
```

A frame's furniture by part, and the translation its layers draw under.

# `axis`

```elixir
@spec axis(term(), term(), term()) :: {:ok, Macaw.Draw.Axis.t()} | {:error, list()}
```

The `Macaw.Draw.Axis` an axis node describes over the model's realized scale (§3.2),
its derived defaults filled from the model's geometry: `{:ok, axis}`, or a fault at the
axis's path for a scale the frame does not realize or cannot draw an axis on. Options
as the module says, and `:length` (the axis's length in pixels, its range's span by
default) and `:run` (the side its labels are spaced as, its own by default).

# `axis_nodes`

```elixir
@spec axis_nodes(Macaw.Frame.Coordinates.Model.t()) :: [map()]
```

The frame's axis nodes, as written.

# `cartesian`

```elixir
@spec cartesian(Macaw.Frame.Coordinates.Model.t(), keyword()) ::
  {:ok, parts() | [Macaw.Draw.IR.Element.t()]} | {:error, list()}
```

The cartesian parts of a model (§3.1, §3.2): the grid of every axis asking for one, the
axes at their sides, the legend and the labels; `axes` is the list of a frame's axis
nodes to draw (all by default). The answer of a model's `furniture/2` with `parts:
true`, and its flat list without.

# `compose`

```elixir
@spec compose(term(), term(), term()) ::
  {:ok, [Macaw.Draw.IR.Element.t()]} | {:error, list()}
```

The frame's groups in order (§3): its model's grid, the layers given (each an element,
or `{element, order}` with `order` `:beneath` drawn first), its axes, its legend and its
labels. In a model whose layers draw about an origin (the polar model's center) the
grid, the layers and the model's own axes share one group translated there.

---

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