TermUI.Widgets.BarChart (TermUI v0.2.0)
View SourceBar chart widget for displaying comparative values.
Renders horizontal or vertical bars proportional to data values. Supports multiple series, labels, and color coding.
Usage
BarChart.render(
data: [
%{label: "Sales", value: 150},
%{label: "Revenue", value: 200},
%{label: "Profit", value: 75}
],
direction: :horizontal,
width: 40,
show_values: true
)Options
:data- List of data points with label and value:direction- :horizontal or :vertical (default: :horizontal):width- Chart width in characters (max: 1000):height- Chart height for vertical charts (max: 500):show_values- Display value labels (default: true):show_labels- Display bar labels (default: true):bar_char- Character for bars (default: "█"):empty_char- Character for empty space (default: " "):colors- List of colors for series
Summary
Functions
@spec bar(keyword()) :: TermUI.Component.RenderNode.t()
Creates a simple horizontal bar for a single value.
Options
:value- Current value (required):max- Maximum value (required):width- Bar width (default: 20, max: 1000):bar_char- Bar character (default: "█"):empty_char- Empty character (default: "░")
@spec render(keyword()) :: TermUI.Component.RenderNode.t()
Renders a bar chart.
Options
:data- List of%{label: String.t(), value: number()}(required):direction- :horizontal or :vertical (default: :horizontal):width- Chart width (default: 40, max: 1000):height- Chart height for vertical (default: 10, max: 500):show_values- Show value labels (default: true):show_labels- Show bar labels (default: true):bar_char- Bar character (default: "█"):colors- List of colors for bars:style- Style for the chart