BarPlot
Builder for creating bar charts. Supports three modes depending on how data is added:- Simple — one bar per category via
with_bar()orwith_bars() - Grouped — multiple side-by-side bars per category via
with_group() - Stacked — bars stacked vertically via
with_group()+with_stacked()
Constructor
Create a bar plot with default settings.Defaults:
- Bar width:
0.8(as a fraction of available slot) - No stacking
- No legend
Simple Mode Methods
"steelblue"). Use with_color() afterwards to change all bars at once.Example:with_bar() for each item. Chain with_color() to set a uniform color.Example:Grouped/Stacked Mode Methods
values is a (value, color) pair — one per series. Call this once per x-axis category. Pair with with_legend() to label the series.Example:Styling Methods
with_bar() / with_bars(). Not needed in grouped/stacked mode, where colors are set per-value in with_group().0.8). Values between 0.0 and 1.0. A width of 1.0 means bars touch.with_group().Legend Methods
Types
BarGroup
A single category group containing one or more bars. Fields:label: String- Category labelbars: Vec<BarValue>- Bar segments in this group
BarValue
A single bar segment with a value and a fill color. Fields:value: f64- Bar height/valuecolor: String- Fill color (CSS color string)