The budget picks each layer's renderer (spec/10 §2.7), copied from visualize's
Visualize.Chart.Compiled targets (its spec/14 §12.3) and .Compiled.Regions.
choose(layer, frame, mode) picks a layer's target when the frame compiles (a
document, binding, budget or size change), never per delivery, so a layer's DOM is
stable through a stream (visualize D-66). It reads what compilation knows, never a
delivered row:
- Outside live mode every layer is
:svg(macaw_component 02 §3): socketless, neutral and print draw no canvas. - A text layer, a tile layer and a facet's layer are
:svg, whatever they say: the binary stream carries no text, tiles are the backdrop, a facet's panels are SVG. A layer is a text or tile layer when its kind draws on:svgalone (itstargets/0). - A layer's own
render:(:svg,:canvas,:binary) is taken as given in live mode, the document's override. - A scrolling plot is
:incremental: a frame whose viewport is a relative window (%{scale: s, span: n}, spec/03 §6.3) over a:linearor:timex scale, every other scale its layers read fixed. Any other moving scale makes every tick a full redraw, so the layer is:binaryinstead. - Otherwise the budget decides. A layer whose slot's budget (
Macaw.Frame.Budget, the rows its pixel extent allows) exceeds the ceiling (1,000 drawn points by default, the Frame'sceiling:option) is:binary, one at or under it:svg; and a high-rate layer is:binarywhatever its budget, one whose slot's schema declares a field's continuity under 1 second (macaw_data 01).
Choosing from the budget, not the delivered count, is the change from visualize: the
first live render already draws on the target the stream keeps, and a page never flips
a layer from SVG to canvas when its data fills. targets(value) reports
[{layer, target, budget}] in layer order.
Summary
Types
What compilation knows of a layer's frame and slot: whether it is a facet, whether
it scrolls (:incremental for a relative window over a linear or time x with every
other scale fixed, :binary for one with another moving scale, nil for none), the
slot's budget, the ceiling, and whether its source is high_rate.
A layer's target.
Functions
The target of layer (a compiled layer: its render and its kind's module) in
frame (frame/0) and mode, by the five rules above. A term of another shape is
:svg, the target every mode draws.
What compilation knows of layer's frame (frame/0), its slot's budget read from
budgets (%{slot => rows}) and its schema from the context.
Each layer's target and the budget it was chosen from, in layer order: [{index, target, budget}]. A value with no compiled document reports none.
Types
@type frame() :: %{ optional(:facet) => boolean(), optional(:scrolls) => :incremental | :binary | nil, optional(:budget) => pos_integer() | nil, optional(:ceiling) => pos_integer(), optional(:high_rate) => boolean() }
What compilation knows of a layer's frame and slot: whether it is a facet, whether
it scrolls (:incremental for a relative window over a linear or time x with every
other scale fixed, :binary for one with another moving scale, nil for none), the
slot's budget, the ceiling, and whether its source is high_rate.
@type target() :: :svg | :canvas | :binary | :incremental
A layer's target.
Functions
The target of layer (a compiled layer: its render and its kind's module) in
frame (frame/0) and mode, by the five rules above. A term of another shape is
:svg, the target every mode draws.
iex> layer = %{render: :auto, module: nil}
iex> Macaw.Frame.Render.Target.choose(layer, %{budget: 5_000}, :live)
:binary
iex> Macaw.Frame.Render.Target.choose(layer, %{budget: 5_000}, :print)
:svg
@spec frame(Macaw.Frame.Compiled.t(), map(), map(), map()) :: frame()
What compilation knows of layer's frame (frame/0), its slot's budget read from
budgets (%{slot => rows}) and its schema from the context.
@spec targets(Macaw.Frame.Value.t()) :: [ {non_neg_integer(), target(), pos_integer() | nil} ]
Each layer's target and the budget it was chosen from, in layer order: [{index, target, budget}]. A value with no compiled document reports none.