Macaw.Frame.Layer.Summary (macaw_frame v0.1.0)

Copy Markdown View Source

A layer's text-summary contribution (spec/04 §1.11): what summary/3 of a layer kind answers, from which the frame's text summary is assembled (spec/11).

  • kind - the chart word the layer gives its frame when it is the first data layer, or nil;
  • auxiliary - true for a kind that annotates rather than draws data (rule, band, x_band, text, tiles): its rows are not counted and it names no kind;
  • series - its series values in order, by declared names where the schema has them;
  • count - the rows it drew (placed rows, not the delivery's);
  • extremes - per series, the label of what is measured and the rows holding the least and the greatest reading, by declared identity where there is one;
  • reach - the items keyboard reach visits for this layer, in order: per series, its rows by x, every row, unsampled;
  • value - the channel whose reading the extremes and the keyboard's readouts are of ("y" for a line, "median" for a percentile band), nil for a kind that draws no number;
  • where - the channel, or the channels, whose readings say where a row is ("x" for a line, ["x0", "y0"] for a heatmap's cells), [] where a row is said by its name alone (spec/11 §2.3, §5.1).

extremes/4 computes the extremes from a pixel column and a value column with one pass over each, never per row through the table.

Summary

Functions

The extremes of a value column per series (§1.11): for each series value in series (in order), the indices of the rows holding its least and greatest reading among values, a number per row or nil, and label the measure's label. One pass over the columns.

A kind's contribution over its table (§1.11): word its chart word (or nil), its placed rows those whose required channels are all placed, its series by declared names, its extremes over the value channel's field per series, its reach per series by x. Options: auxiliary: true for a kind that annotates; where: the channel or channels that say where a row is ("x" by default, [] for a kind with no value); count: :elements to count differently is the kind's own.

The frame's kind word decided across its layers' contributions and its model (§1.11): a geographic frame is a map; any needle makes a gauge; a layout names its layout; otherwise the first non-auxiliary layer's word.

Types

extreme()

@type extreme() :: %{
  series: term(),
  label: String.t() | nil,
  least: non_neg_integer() | nil,
  greatest: non_neg_integer() | nil
}

t()

@type t() :: %Macaw.Frame.Layer.Summary{
  auxiliary: boolean(),
  count: non_neg_integer(),
  extremes: [extreme()],
  kind: String.t() | nil,
  reach: [non_neg_integer()],
  series: [term()],
  value: String.t() | nil,
  where: String.t() | [String.t()]
}

Functions

extremes(values, series_column, series, label)

@spec extremes([number() | nil], list(), list(), String.t() | nil) :: [extreme()]

The extremes of a value column per series (§1.11): for each series value in series (in order), the indices of the rows holding its least and greatest reading among values, a number per row or nil, and label the measure's label. One pass over the columns.

iex> Macaw.Frame.Layer.Summary.extremes([3, 1, 4, 2], [nil, nil, nil, nil], [nil], "v")
[%{series: nil, label: "v", least: 1, greatest: 2}]

of(layer, table, model, word, value, required, opts \\ [])

@spec of(
  map(),
  Macaw.Data.Table.t(),
  Macaw.Frame.Coordinates.Model.t(),
  String.t() | nil,
  String.t() | nil,
  [String.t()],
  keyword()
) :: t()

A kind's contribution over its table (§1.11): word its chart word (or nil), its placed rows those whose required channels are all placed, its series by declared names, its extremes over the value channel's field per series, its reach per series by x. Options: auxiliary: true for a kind that annotates; where: the channel or channels that say where a row is ("x" by default, [] for a kind with no value); count: :elements to count differently is the kind's own.

word(summaries, model, kinds)

@spec word([t()], atom(), [String.t()]) :: String.t() | nil

The frame's kind word decided across its layers' contributions and its model (§1.11): a geographic frame is a map; any needle makes a gauge; a layout names its layout; otherwise the first non-auxiliary layer's word.

iex> alias Macaw.Frame.Layer.Summary
iex> Summary.word([%Summary{auxiliary: true}, %Summary{kind: "line chart"}], :cartesian, [])
"line chart"
iex> Summary.word([%Summary{kind: "line chart"}], :cartesian, ["needle"])
"gauge"