The budget hint and the slot's reducer (spec/04 §1.10).
A kind's budget/2 is the rows it needs at a plot width w in whole pixels, by its
class (hint/2):
| Class | Kinds | Rows at width w |
|---|---|---|
:continuous | line, area, percentile_band, violin | 4 × w: M4's lossless bound |
:bars | rect, band, rose, box | ceil(w / 2): a bar per two pixels |
:candles | candle | ceil(w / 3): a candle per three pixels, its body and the gap beside it |
:row | every other kind that reads rows | w |
:none | tiles | nil: reads no rows |
A hint is monotone non-decreasing in w and at least 1 for every w ≥ 1.
From its layers' hints the Frame answers macaw_component's budget/3 for each slot
(slot/3): the largest need of the layers reading the slot, or the document's own
budget where it declares one, a layer through a delaunay or voronoi step asking
at most 2,000 rows (triangulation_cap/0); and the slot's reducer: whole when
any reader passes its rows through a step that needs every row, "m4" when any reader
is a continuous kind, the host's default "lttb" otherwise.
Summary
Functions
A delivery for a triangulating layer kept to the cap (§1.10): {table, capped?}, the
first 2,000 rows in the slot's order when there are more.
The rows a kind of class needs at width w (§1.10).
A slot's budget and reducer from the checked layers reading it (§1.10): %{budget: rows | nil, reducer: :whole | "m4" | "lttb"} at plot width w. Options: budget: the
document's own budget for the slot, which wins over the layers' needs.
Whether a layer's steps include a triangulating one (delaunay, voronoi).
The rows a layer through a triangulating step asks for at most: 2,000.
Types
Functions
@spec capped(map(), Macaw.Data.Table.t()) :: {Macaw.Data.Table.t(), boolean()}
A delivery for a triangulating layer kept to the cap (§1.10): {table, capped?}, the
first 2,000 rows in the slot's order when there are more.
@spec hint(class(), term()) :: pos_integer() | nil
The rows a kind of class needs at width w (§1.10).
iex> alias Macaw.Frame.Layer.Budget
iex> {Budget.hint(:continuous, 640), Budget.hint(:bars, 641), Budget.hint(:candles, 640), Budget.hint(:row, 640)}
{2560, 321, 214, 640}
iex> Budget.hint(:none, 640)
nil
@spec slot([map()], number(), keyword()) :: %{ budget: pos_integer() | nil, reducer: term() }
A slot's budget and reducer from the checked layers reading it (§1.10): %{budget: rows | nil, reducer: :whole | "m4" | "lttb"} at plot width w. Options: budget: the
document's own budget for the slot, which wins over the layers' needs.
Whether a layer's steps include a triangulating one (delaunay, voronoi).
@spec triangulation_cap() :: 2000
The rows a layer through a triangulating step asks for at most: 2,000.