A vertical or horizontal bar chart widget.
Each entry in :data is a ExRatatui.Widgets.Bar struct carrying a label
and a non-negative integer value. Chart-level :bar_style, :value_style,
and :label_style apply to every bar by default; individual bars can
override their color via their own :style field, or replace the numeric
display via :text_value.
Grouped bars
Use :groups instead of :data to render side-by-side clusters of bars
with a shared caption — handy when comparing the same metrics across
categories (months, products, regions). Each entry is a
%ExRatatui.Widgets.BarGroup{label, bars}; :group_gap controls the
spacing between clusters.
Set either :data or :groups, not both.
Fields
:data- list of%ExRatatui.Widgets.Bar{}(default[]); rendered as a single anonymous group:groups- list of%ExRatatui.Widgets.BarGroup{}for multi-cluster charts (default[]):bar_width- width (vertical) or height (horizontal) of each bar in cells; default1:bar_gap- cells between adjacent bars; default1:group_gap- cells between adjacent groups when:groupsis used; default0:bar_style- shared%ExRatatui.Style{}applied to bars without a per-bar override:value_style-%ExRatatui.Style{}for the numeric value text:label_style-%ExRatatui.Style{}for bar labels:max- optional upper bound; whennil, the chart auto-scales to the largest value:direction-:vertical(default) or:horizontal:block- optional%ExRatatui.Widgets.Block{}container
Examples
iex> alias ExRatatui.Widgets.{Bar, BarChart}
iex> %BarChart{data: [%Bar{label: "Elixir", value: 80}, %Bar{label: "Rust", value: 95}]}
%ExRatatui.Widgets.BarChart{
data: [
%ExRatatui.Widgets.Bar{label: "Elixir", value: 80, style: nil, text_value: nil},
%ExRatatui.Widgets.Bar{label: "Rust", value: 95, style: nil, text_value: nil}
],
groups: [],
bar_width: 1,
bar_gap: 1,
group_gap: 0,
bar_style: %ExRatatui.Style{},
value_style: %ExRatatui.Style{},
label_style: %ExRatatui.Style{},
max: nil,
direction: :vertical,
block: nil
}
Summary
Types
@type direction() :: :vertical | :horizontal
@type t() :: %ExRatatui.Widgets.BarChart{ bar_gap: non_neg_integer(), bar_style: ExRatatui.Style.t(), bar_width: pos_integer(), block: ExRatatui.Widgets.Block.t() | nil, data: [ExRatatui.Widgets.Bar.t()], direction: direction(), group_gap: non_neg_integer(), groups: [ExRatatui.Widgets.BarGroup.t()], label_style: ExRatatui.Style.t(), max: nil | non_neg_integer(), value_style: ExRatatui.Style.t() }