Visualize.Board.State (Visualize v0.7.0)

Copy Markdown View Source

A cell's state, decided and drawn (spec/15 §8.4, D-146).

A cell is always in one state, and every state is drawn deliberately: never a blank chart, a crash or a host's spinner. of/3 decides the state of a cell's slots at the board's now; render/3 draws it as the whole cell, where there is no chart, and banner/3 as one line across the top of a chart, where the last data stays readable. Each state has a role (spec/08 §7.5, D-135): its color is the drawing's accent and its cue's glyph (spec/14 §21.7, D-142) stands beside the words, so a state reads in grayscale as well. Both drawings are in :css mode, so a stylesheet themes them as it themes the charts.

StateRoleWords
{:crashed, reason}:badCrashed, restarting
{:down, reason}:badFeed down and the reason
{:invalid, errors}:badWrong binding and the first fault
:loading:infoLoading…
:no_data:neutralNo data yet
{:stale, age}:warningStale and the age
:capped:infoCapped: part of the window
:live——

Examples

iex> Visualize.Board.State.words({:stale, 330})
"Stale: 5m30s old"
iex> Visualize.Board.State.role(:no_data)
:neutral
iex> Visualize.Board.State.banner(:live, Visualize.Theme.default(), 300)
nil

Summary

Types

What a cell knows of one slot: its delivery, the delivery's schema and the feed's status.

t()

Functions

A state drawn as a banner across the top of a chart width wide (spec/15 §8.4): an SVG root one line high, the role's color behind the role's glyph and the words in the contrast ink of Visualize.Theme.ink/2. nil for :live, which needs none. id: as render/4 takes it; a board passes <cell root id>-banner (#722).

A state's name, the data-vis-state its drawings carry: "stale", "down", …

The state of a cell's slots at now (spec/15 §8.4), the first that holds of: down (a slot's feed is down), loading (a slot has no delivery yet), no data (every delivery empty), stale (a feed the monitor calls stale, or a newest DateTime reading older than stale_after seconds at now), capped (a delivery is capped), and live. A cell with no slots is live. Crashed is the board's, which draws it for a cell that cannot.

A state drawn as the whole cell (spec/15 §8.4): an accessible SVG root of {w, h} titled with the words, the theme's surface filling it inside a frame of the role's color, and the role's glyph and the words centered in the theme's text. :live is drawn as the empty surface.

A state's role (spec/08 §7.5), whose color and glyph draw it; nil for :live.

A state's words, as the drawings print them; "" for :live.

Types

slot()

@type slot() :: %{
  delivery: Visualize.Data.Delivery.t() | nil,
  schema: Visualize.Data.Schema.t() | nil,
  status: Visualize.Feed.Monitor.status()
}

What a cell knows of one slot: its delivery, the delivery's schema and the feed's status.

t()

@type t() ::
  :loading
  | :no_data
  | :live
  | :capped
  | {:stale, number() | nil}
  | {:down, term()}
  | {:invalid, [Visualize.Chart.Validator.error(), ...]}
  | {:crashed, term()}

Functions

banner(state, theme, width, opts \\ [])

@spec banner(t(), Visualize.Theme.t(), number(), keyword()) :: String.t() | nil

A state drawn as a banner across the top of a chart width wide (spec/15 §8.4): an SVG root one line high, the role's color behind the role's glyph and the words in the contrast ink of Visualize.Theme.ink/2. nil for :live, which needs none. id: as render/4 takes it; a board passes <cell root id>-banner (#722).

name(state)

@spec name(t()) :: String.t()

A state's name, the data-vis-state its drawings carry: "stale", "down", …

of(slots, now, stale_after)

@spec of(%{required(atom()) => slot()}, DateTime.t() | nil, number() | nil) :: t()

The state of a cell's slots at now (spec/15 §8.4), the first that holds of: down (a slot's feed is down), loading (a slot has no delivery yet), no data (every delivery empty), stale (a feed the monitor calls stale, or a newest DateTime reading older than stale_after seconds at now), capped (a delivery is capped), and live. A cell with no slots is live. Crashed is the board's, which draws it for a cell that cannot.

render(state, theme, arg, opts \\ [])

@spec render(t(), Visualize.Theme.t(), {number(), number()}, keyword()) :: String.t()

A state drawn as the whole cell (spec/15 §8.4): an accessible SVG root of {w, h} titled with the words, the theme's surface filling it inside a frame of the role's color, and the role's glyph and the words centered in the theme's text. :live is drawn as the empty surface.

id: is the root's id and its title's id stem (spec/14 §4.7, D-188): a board passes the cell's root id, so two cells in one state never share one (#722). Without it the id is derived from the title.

role(arg1)

@spec role(t()) :: Visualize.Theme.slot() | nil

A state's role (spec/08 §7.5), whose color and glyph draw it; nil for :live.

words(arg1)

@spec words(t()) :: String.t()

A state's words, as the drawings print them; "" for :live.