class RatatuiRuby::Widgets::BarChart

Displays categorical data as bars.

Raw tables of numbers are hard to scan. Comparing magnitudes requires mental arithmetic, which slows down decision-making.

This widget visualizes the data. It renders vertical bars proportional to their value.

Use it to compare server loads, sales figures, or any discrete datasets.

Example

Run the interactive demo from the terminal:

ruby examples/widget_barchart/app.rb

# Grouped Bar Chart
BarChart.new(
  data: [
    BarGroup.new(label: "Q1", bars: [Bar.new(value: 40), Bar.new(value: 45)]),
    BarGroup.new(label: "Q2", bars: [Bar.new(value: 50), Bar.new(value: 55)])
  ],
  bar_width: 5,
  group_gap: 3
)