TermUI.Widgets.BarChart (TermUI v0.2.0)

View Source

Bar 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

Creates a simple horizontal bar for a single value.

Renders a bar chart.

Functions

bar(opts)

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: "░")

render(opts)

@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