ExRatatui.Widgets.Sparkline (ExRatatui v0.8.2)

Copy Markdown View Source

A compact inline chart for a single data series.

Each entry in :data is either a non-negative integer sample or nil for a missing/absent sample. Absent samples render with the configurable :absent_value_symbol (default " ") and :absent_value_style, which lets you distinguish gaps from zeros.

Fields

  • :data - list of non_neg_integer() | nil samples (required; may be empty)

  • :style - chart-wide %ExRatatui.Style{}; falls back to terminal default
  • :max - optional upper bound; when nil, the chart auto-scales to the largest value
  • :direction - :left_to_right (default) or :right_to_left
  • :bar_set - glyph set used to draw the bars:
    • :nine_levels (default, full-block gradient)
    • :three_levels (low/medium/high)
    • a list of strings from empty to full, e.g. [" ", "▂", "▅", "█"]
  • :absent_value_style - %ExRatatui.Style{} applied to gap cells
  • :absent_value_symbol - grapheme rendered for nil samples (default " ")
  • :block - optional %ExRatatui.Widgets.Block{} container

Examples

iex> alias ExRatatui.Widgets.Sparkline
iex> %Sparkline{data: [0, 1, 3, 7, 3, 1, 0]}
%ExRatatui.Widgets.Sparkline{
  data: [0, 1, 3, 7, 3, 1, 0],
  style: nil,
  max: nil,
  direction: :left_to_right,
  bar_set: :nine_levels,
  absent_value_style: nil,
  absent_value_symbol: nil,
  block: nil
}

Summary

Types

bar_set()

@type bar_set() :: :nine_levels | :three_levels | [String.t()]

direction()

@type direction() :: :left_to_right | :right_to_left

t()

@type t() :: %ExRatatui.Widgets.Sparkline{
  absent_value_style: ExRatatui.Style.t() | nil,
  absent_value_symbol: String.t() | nil,
  bar_set: bar_set(),
  block: ExRatatui.Widgets.Block.t() | nil,
  data: [non_neg_integer() | nil],
  direction: direction(),
  max: nil | non_neg_integer(),
  style: ExRatatui.Style.t() | nil
}