The frame's legend (spec/03 §3.3): its entries, its placement, and whether it is drawn, all from one layout, so the drawing, the extent, the margin it takes and its fit cannot disagree.
- Entries (§3.3.1): one per
Macaw.Draw.Scale.ticks/2value of the scale (five of a continuous one), or one per declared value withvalues; a 12 × 12 swatch and, 16 to its right, its label as the axis prints it withprefixandunit. A value with a declared name in its slot's schema is labeled by the name. Each entry's group carriesdata-series, the value's string. - Placement (§3.3.2): a corner or a side, inside the plot 8 from its edges or in a
margin 8 out from it; a top or bottom row wraps to the plot's width and in a margin
grows that margin,
(rows − 1) × 16 + 12 + 8.max_labelcuts a label tomax_label − 1characters and…, the full label kept as its<title>andaria-label. Text widths are the Frame's measurer's (Macaw.Draw.Text.width/3, macaw_layers#59), the estimate by default. - Omission (§3.3.3): a legend that cannot be laid out is omitted, not a fault: no
group, no margin, extent zero; the reason the first of
:min_entries,:cell,:row,:height,:widththat holds. - Fit (§3.3.4):
status/2is the model'slegend_fit,extent/2its box less the 8.
The options: :theme, :mode, :styles (the design's styles), :schemas (each
slot's schema, for declared names) and :bindings (the cell's binding of each slot's
roles to the schema's fields). Copied from visualize's Visualize.Chart.Frame.Legend.
Summary
Types
Why a legend is omitted (§3.3.3).
Functions
The box the legend is laid out in, %{width, height}, not counting the 8 between it
and the plot (§3.3.4); zero with no legend or an omitted one.
The margin the frame takes for its legend (§3.3.2): its own, with a top or bottom margin
of a legend inside: false grown to the legend's rows. An omitted legend takes none.
The legend group, [] when the frame has no legend or its legend is omitted (§3.3).
The paint an entry's swatch is filled with (§3.3.1): a literal color as itself, a color
value (a role, a series, a ramp position) resolved against theme in mode (:css or
:literal), and anything else, or a color value that resolves to nothing, the theme's
series role at the entry's one-based position. The shared Legend paints its entries
with it (spec/01 §7), so both legends show a value in one color. A wrong-typed
position, theme or mode is a type fault at its argument.
Whether the legend is drawn (§3.3.4): nil with no legend, %{status: :drawn, entries: n}, or %{status: :omitted, reason: r, entries: n}.
An entry's swatch (§3.3.1): the 12 × 12 square filled with paint (paint/4's answer),
its left edge at x. Every entry of the frame's legend is drawn with it, and every entry
of the shared Legend (spec/01 §7). A non-numeric x is a type fault at [1].
Types
Functions
The box the legend is laid out in, %{width, height}, not counting the 8 between it
and the plot (§3.3.4); zero with no legend or an omitted one.
The margin the frame takes for its legend (§3.3.2): its own, with a top or bottom margin
of a legend inside: false grown to the legend's rows. An omitted legend takes none.
@spec generate(term(), term()) :: [Macaw.Draw.IR.Element.t()]
The legend group, [] when the frame has no legend or its legend is omitted (§3.3).
@spec paint(term(), term(), term(), term()) :: Macaw.Layers.Color.t() | String.t() | :none | {:error, [{list(), term()}, ...]}
The paint an entry's swatch is filled with (§3.3.1): a literal color as itself, a color
value (a role, a series, a ramp position) resolved against theme in mode (:css or
:literal), and anything else, or a color value that resolves to nothing, the theme's
series role at the entry's one-based position. The shared Legend paints its entries
with it (spec/01 §7), so both legends show a value in one color. A wrong-typed
position, theme or mode is a type fault at its argument.
Whether the legend is drawn (§3.3.4): nil with no legend, %{status: :drawn, entries: n}, or %{status: :omitted, reason: r, entries: n}.
@spec swatch(term(), term()) :: Macaw.Draw.IR.Element.t() | {:error, [{list(), term()}, ...]}
An entry's swatch (§3.3.1): the 12 × 12 square filled with paint (paint/4's answer),
its left edge at x. Every entry of the frame's legend is drawn with it, and every entry
of the shared Legend (spec/01 §7). A non-numeric x is a type fault at [1].