Skip to main content

BarChart

Vertical or horizontal bar chart with optional per-bar style overrides.

Usage

const bars = [_]tui.widgets.Bar{
.{ .label = "Jan", .value = 42 },
.{ .label = "Feb", .value = 75, .style = .{ .fg = .yellow } },
.{ .label = "Mar", .value = 31 },
};

tui.widgets.BarChart{
.bars = &bars,
.max = 100, // null → auto-scale
.direction = .vertical, // or .horizontal
.bar_width = 5,
.bar_gap = 1,
.bar_style = .{ .fg = .cyan },
.bar_char = '█',
.empty_char = '░',
}.render(area, buf);

Fields

FieldTypeDefaultDescription
bars[]const BarData bars
max?u64nullScale ceiling
direction.vertical / .horizontal.verticalChart orientation
bar_widthu163Width of each bar (vertical mode)
bar_gapu161Gap between bars
bar_charu21'█'Filled cell character
empty_charu21' 'Empty cell character