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

The cartesian model (spec/03 §6): position scales `x` and `y`, their offsets, `color`
and any other scale its axes and layers name. The default model, and the one a
Sparkline uses.

- **Placement** (§6.2): `place/2` is `{x(a), y(b)}`; through a band a position channel
  lands at the band's center, an edge channel `x0` at its start and `x1` at its end, an
  offset inside it (`position/4`). A reading a scale cannot place places nothing. The
  default margin is `%{top: 20, right: 20, bottom: 30, left: 40}`.
- **The viewport** (§6.3): `viewport: %{scale: s, span: n}` makes `s` a streaming window,
  its domain `[hi − n, hi]` on each delivery, `hi` the newest reading of the channels
  naming it, given through `domains` so nothing infers it (a time span in seconds).
- **Brush, zoom and pan** (§6.4): a brush and a zoom over a `linear` or `time` `x`; a
  moving brush travels only as `<group>.brush`; a finished one emits `"brush"`, a band
  under five pixels nothing and one under a pixel a pick (spec/05 §6.1); a zoom or pan
  emits `"zoom"` only when it needs more detail; a double-click `"reset"`.
- **Hit-testing and summary** (§6.5): items by the hit index, the crosshair's nearest
  datum per series by `x` (`nearest/2` over `series/2`), and the summary "chart" with
  each axis's title, kind and extent.

Copied from visualize's `Visualize.Chart.Frame` (`:cartesian`) and
`Visualize.Chart.Compiled.Window` (the viewport).

# `margin`

```elixir
@spec margin() :: map()
```

The margin a cartesian frame draws with when it gives none (§6.2).

# `nearest`

```elixir
@spec nearest(map(), term()) :: %{required(term()) =&gt; {term(), term()}}
```

The crosshair's nearest datum per series by `x` (§6.5): for each series of `series/2`,
`{x, y}` of the reading whose `x` is nearest the value, `nil` dropped.

# `position`

```elixir
@spec position(Macaw.Frame.Coordinates.Model.t(), String.t(), term(), term()) ::
  number() | nil
```

One channel's reading in plot pixels (§6.2): through its family's scale, a band's
center for a position channel, its start for `x0`/`y0` and its end for `x1`/`y1`; with
an `offset` reading the inner band added inside it. `nil` for a reading the scale
cannot place.

# `series`

```elixir
@spec series(Macaw.Frame.Coordinates.Model.t(), map()) :: %{
  required(term()) =&gt; %{x: list(), y: list()}
}
```

The data arrays the Frame writes for the crosshair (§6.5): each series' `x` values and
`y` values in domain units, from the layers' tables read by column, by the `series`
reading (`"default"` for a layer with none).

---

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