BarChartWidget
A themed bar chart. Paint-only, and an ordinary Ratatui widget — no Ratcn runtime needed, just frame.render_widget(...).
use ratatui::widgets::Bar;
use ratcn::BarChartWidget;
let bars = vec![
Bar::default().label("Mon").value(12),
Bar::default().label("Tue").value(18),
Bar::default().label("Wed").value(9),
];
frame.render_widget(BarChartWidget::new(bars).themed(&theme), area);Bars run upward by default; BarChartWidget::vertical(...) is the same constructor under a clearer name. Size the area to what the bars occupy — bars × bar_width + gaps — or the chart's background runs past the last bar.
Scale
By default the tallest bar fills the chart, so the scale moves whenever the data does. Pin it with .max_value(...) for a chart that updates live or that should be comparable with another chart.
BarChartWidget::new(bars).themed(&theme).max_value(24)Horizontal
BarChartWidget::horizontal(...) runs the bars across instead of up. Each bar gets a whole row to itself, so labels have room to be phrases rather than abbreviations — usually the reason to choose this direction.
BarChartWidget::horizontal(bars)
.themed(&theme)
.bar_width(1) // a horizontal bar's "width" is its height, in rows
.bar_gap(0)Grouped
BarChartWidget::grouped(...) clusters bars so several series can be compared across categories. Groups are BarChartGroup values rather than Ratatui's BarGroup, so widget-level options such as .show_values(false) apply to grouped bars too. Set .direction(Direction::Horizontal) for horizontal groups. Horizontal group labels occupy the space reserved by .group_gap(...) and are not drawn when that gap is 0.
use ratcn::BarChartGroup;
BarChartWidget::grouped(vec![
BarChartGroup::with_label("Q1", q1_bars),
BarChartGroup::with_label("Q2", q2_bars),
])
.themed(&theme)
.group_gap(2)Bar Shape
.bar_width(...) and .bar_gap(...) size the bars; .group_gap(...) adds space between clusters in a grouped chart. .show_values(false) hides the number printed inside each bar, for bars too narrow to fit one.
A vertical bar rarely ends exactly on a cell boundary, so its top cell is drawn with a partial block. .bar_set(...) chooses those glyphs — the default gives the smoothest result, and coarser sets exist for terminals whose fonts lack them. Horizontal bars use whole cells and only use the set's full and empty symbols.
use ratatui::symbols;
BarChartWidget::new(bars)
.themed(&theme)
.show_values(false)
.bar_set(symbols::bar::THREE_LEVELS)Styling
.themed(&theme) derives every color from the active theme. Use .style(BarChartStyle) for explicit colors, starting from BarChartStyle::from_theme(...) or from BarChartStyle::fallback() when there is no theme:
use ratcn::BarChartStyle;
let mut style = BarChartStyle::from_theme(&theme);
style.bar = theme.accent;
BarChartWidget::new(bars).style(style)Full API
Every method, with parameter and edge-case detail: BarChartWidget, BarChartGroup, BarChartStyle.