class

Phosphor::SparkLineMock

Inherits Phosphor::MockWidget < Reference < Object

A rolling time-series spark line rendered as a row (or stacked block) of Unicode block characters.

Generic and app-agnostic: no knowledge of AppState, Msg, or the application theme. The Widget wrapper resolves theme → Style values and sets them in Props before each render.

Display-only: SparkLineMock has no WidgetState of its own and no Cmds to respond to — handle_cmd always returns CmdResult::None. It is driven entirely by Props#values, so a new reading is shown simply by passing an updated Props on the next render.

Constants

BLANK_STYLE = (Style.new.fg(Color::Default.new)).bg(Color::Default.new)

A Style that clears fg/bg back to the terminal's own default, explicitly (Color::Default, not nil) — see Buffer#set_string's doc comment on why that distinction matters when padding cells that might sit over a previously-styled background.

BLOCKS = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]

The eight block-element glyphs, in ascending fill order, used to render a value's relative height — both for render_single_row's one-glyph-per-value mode and as the per-row fill granularity in render_multi_row's stacked mode.

Constructors

new(props : Props = Props.new, state : WidgetState = WidgetState.new)

Initialises the spark line with props and an optional state.

Source

Instance methods

handle_cmd(cmd : Cmd) : CmdResult

SparkLineMock is purely display-driven by Props — it has no Cmds of its own, so this always returns CmdResult::None.

Source
props
Source
props=(props : Props)
Source
render_content(frame : Frame, buf : Buffer) : Void

Renders the rightmost frame.width values of props.values into buf within frame.

At frame.height == 1, each value draws as a single block glyph (render_single_row). At any greater height, values are drawn as a stacked bar chart spanning every row (render_multi_row). Does nothing if props.values is empty or frame has no area.

Source

Nested types