TermUI.Widgets.Gauge (TermUI v0.2.0)
View SourceGauge widget for displaying a single value within a range.
Shows value as a bar or arc with min/max labels and optional color zones for visual feedback.
Usage
Gauge.render(
value: 75,
min: 0,
max: 100,
width: 30,
zones: [
{0, :green},
{60, :yellow},
{80, :red}
]
)Display Types
:bar- Horizontal bar (default):arc- Semi-circular arc using block characters
Summary
Functions
Creates a simple percentage gauge.
Renders a gauge.
Creates a gauge with traffic light colors (green/yellow/red).
Functions
@spec percentage( number(), keyword() ) :: TermUI.Component.RenderNode.t()
Creates a simple percentage gauge.
Examples
Gauge.percentage(75, width: 20)
@spec render(keyword()) :: TermUI.Component.RenderNode.t()
Renders a gauge.
Options
:value- Current value (required):min- Minimum value (default: 0):max- Maximum value (default: 100):width- Gauge width (default: 40, max: 1000):type- :bar or :arc (default: :bar):show_value- Show numeric value (default: true):show_range- Show min/max labels (default: true):zones- List of {threshold, style} for color zones:label- Label for the gauge:bar_char- Character for filled portion:empty_char- Character for empty portion
@spec traffic_light(keyword()) :: TermUI.Component.RenderNode.t()
Creates a gauge with traffic light colors (green/yellow/red).
Options
:value- Current value (required):warning- Yellow zone threshold (default: 60):danger- Red zone threshold (default: 80)
Note: You need to provide actual Style structs for the zones to be visible.