Alaja.Components.Bar (Alaja v1.0.0)

Copy Markdown View Source

Static progress bar component for terminal output.

Renders a horizontal bar representing a value as a proportion of a maximum.

Usage

iex> Alaja.Components.Bar.print(75, 100)
# [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%

iex> Alaja.Components.Bar.print(0.6, 1.0, label: "CPU", width: 40)
# CPU [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░] 60%

Summary

Functions

Prints a progress bar directly to stdout.

Renders a progress bar to iodata without printing.

Functions

print(value, max \\ 100, opts \\ [])

@spec print(number(), number(), keyword()) :: :ok

Prints a progress bar directly to stdout.

Parameters

  • value - Current value (numeric)
  • max - Maximum value (numeric, default: 100)

Options

  • :label - Optional label prefix
  • :show_percent - Show percentage at end (default: true)
  • :width - Bar width in chars (default: 40)
  • :filled_char - Character for filled portion (default: "▓")
  • :empty_char - Character for empty portion (default: "░")
  • :filled_color - RGB tuple for filled section
  • :empty_color - RGB tuple for empty section

render(value, max \\ 100, opts \\ [])

@spec render(number(), number(), keyword()) :: iodata()

Renders a progress bar to iodata without printing.