Scale ownership (spec/03 §2): a frame owns its scales, and this module realizes them.
- Realization (§2.1,
realize/5): each scale node once, throughMacaw.Draw.Scale.new/2with its kind's parameters, then the domain, the range,niceandclamp. A node the constructor refuses is a fault at the node's path,{:range, reason}for its range; nothing raises. - Which channel reads which scale (§2.2,
reads/3): the model'schannel_scale/3maps a channel to a family, the layer'sscalesrenames it, itsoffsetadds the offset scale, and a{:field, f}color of its style readscolor. - Inference (§2.3): only inferring scales read data, and they read columns,
Macaw.Data.Table.column/2, never rows. - Automatic ranges (§2.4): the model's
auto_range/3, the theme's series and ramps for colors, an offset's band, else the first axis naming the scale. - Adoption (§2.5,
adoptions/1,unite/1): a scale adopted from another frame is that frame's node, its domain shared, its range each frame's own.
Copied from visualize's Visualize.Chart.Frame.Scales, its raising sites made faults.
Summary
Types
A read: the scale, the layer's input, the channel (or :color, :offset) and its reading.
A realization: the scales by name, those built anew, the extents given, and the scale nodes it realized from.
Functions
The adoption groups of a design (§2.5): the declared scale a chain ends at, {frame, name}, and every {frame, name} reading it, the owner's own entry included. Only a
group whose node infers its domain is listed: a fixed domain is shared already.
The inputs with their compiled scale nodes held for frame (resolved/3), where the
frame they were compiled for declares the same scales: a model realizing a frame it
derives from its own (a facet's inner frame) reads the nodes compiled for it.
The faults a scale node alone decides (§2.1), found at validation: a ramp range on a
kind that takes none, a color map on a scale that is not ordinal, an empty range on a
scale that is not ordinal, each {:range, reason} at the node's range.
One column of a table, nil dropped, the column named by either spelling of field
(§2.3): read through Macaw.Data.Table.column/2, never row by row. [] for a table
without the column, or no table.
Whether a domain is inferred: :auto, :window (a domain following the slot's served
window, inferred where no delivery gives one, spec/05 §3.2), or an extent with :auto
at an end (§2.3).
A realized model's scale nodes: those it realized from, else nodes/3 of its frame
node with no design.
The frame's scale nodes by name, each adopted entry {:frame, f, s} resolved to the node
its chain ends at in design: {:ok, nodes}, or a cycle {:cycle, :scale, name}, an
undeclared frame {:undeclared, :frame, f} or scale {:undeclared, :scale, s} at the
adopting scale's path.
Every read of the frame's layers through module's table (§2.2): {scale, layer, channel, reading} per channel whose family is a declared scale, per {:field, f}
color of the layer's style (:color), and per offset field (:offset). A family the
frame does not declare reads pixels and is not listed. nodes are the frame's scale
nodes by name.
Every scale of frame realized for module over the plot (§2.1): {:ok, %{scales, built, domains}}, or every fault at once.
The undeclared renames of the frame's layers (§2.2): {:undeclared, :scale, name} at
the layer's scales path for a rename to a scale the frame does not declare.
The frame's scale nodes as compiled (spec/12 §2): the nodes the compilation resolved
for this frame, which a model's inputs hold as scale_nodes: %{frame: frame, nodes: nodes}, else nodes/3 of the frame in the inputs' design. A realization reads its
nodes so, and so constructs no scale setup from the frame's declarations per delivery.
One domain over the domains of an adoption group (§2.5): the extent of continuous ones, the categories of discrete ones in order of first appearance.
Types
A read: the scale, the layer's input, the channel (or :color, :offset) and its reading.
@type realized() :: %{ scales: %{required(String.t()) => struct()}, built: [String.t()], domains: map(), nodes: %{required(String.t()) => map()} }
A realization: the scales by name, those built anew, the extents given, and the scale nodes it realized from.
Functions
The adoption groups of a design (§2.5): the declared scale a chain ends at, {frame, name}, and every {frame, name} reading it, the owner's own entry included. Only a
group whose node infers its domain is listed: a fixed domain is shared already.
The inputs with their compiled scale nodes held for frame (resolved/3), where the
frame they were compiled for declares the same scales: a model realizing a frame it
derives from its own (a facet's inner frame) reads the nodes compiled for it.
@spec check(term(), list()) :: [Macaw.Base.Fault.t()]
The faults a scale node alone decides (§2.1), found at validation: a ramp range on a
kind that takes none, a color map on a scale that is not ordinal, an empty range on a
scale that is not ordinal, each {:range, reason} at the node's range.
One column of a table, nil dropped, the column named by either spelling of field
(§2.3): read through Macaw.Data.Table.column/2, never row by row. [] for a table
without the column, or no table.
Whether a domain is inferred: :auto, :window (a domain following the slot's served
window, inferred where no delivery gives one, spec/05 §3.2), or an extent with :auto
at an end (§2.3).
iex> Macaw.Frame.Scales.infers?([0, :auto])
true
iex> Macaw.Frame.Scales.infers?([0, 1])
false
A realized model's scale nodes: those it realized from, else nodes/3 of its frame
node with no design.
The frame's scale nodes by name, each adopted entry {:frame, f, s} resolved to the node
its chain ends at in design: {:ok, nodes}, or a cycle {:cycle, :scale, name}, an
undeclared frame {:undeclared, :frame, f} or scale {:undeclared, :scale, s} at the
adopting scale's path.
Every read of the frame's layers through module's table (§2.2): {scale, layer, channel, reading} per channel whose family is a declared scale, per {:field, f}
color of the layer's style (:color), and per offset field (:offset). A family the
frame does not declare reads pixels and is not listed. nodes are the frame's scale
nodes by name.
Every scale of frame realized for module over the plot (§2.1): {:ok, %{scales, built, domains}}, or every fault at once.
inputs are the model's (Macaw.Frame.Coordinates). Options: :path (the frame's
path, [:frames, name]), :theme, :domains (an extent by name standing in for its
inference), :reuse (a previous realization's scales and plot, %{scales, plot, node}: a fixed scale whose node and plot are unchanged is reused, not built), :zone
(the viewer's display zone, under a node's own).
@spec renames(module(), map(), [map()], map()) :: [Macaw.Base.Fault.t()]
The undeclared renames of the frame's layers (§2.2): {:undeclared, :scale, name} at
the layer's scales path for a rename to a scale the frame does not declare.
@spec resolved(term(), term(), list()) :: {:ok, %{required(String.t()) => map()}} | {:error, list()}
The frame's scale nodes as compiled (spec/12 §2): the nodes the compilation resolved
for this frame, which a model's inputs hold as scale_nodes: %{frame: frame, nodes: nodes}, else nodes/3 of the frame in the inputs' design. A realization reads its
nodes so, and so constructs no scale setup from the frame's declarations per delivery.
One domain over the domains of an adoption group (§2.5): the extent of continuous ones, the categories of discrete ones in order of first appearance.
iex> Macaw.Frame.Scales.unite([[0, 5], [-2, 3]])
[-2, 5]
iex> Macaw.Frame.Scales.unite([["a", "b"], ["c", "a"]])
["a", "b", "c"]