pub enum BarWidth {
Fixed(u32),
Percentage(f32),
Auto,
}Expand description
Bar width configuration options.
Determines how the width of bars is calculated based on the available chart space and the number of data points.
§Examples
use embedded_charts::prelude::*;
// Fixed width bars
let fixed = BarWidth::Fixed(20); // 20 pixels wide
// Percentage width (80% of available space per bar)
let percentage = BarWidth::Percentage(0.8);
// Automatic width calculation
let auto = BarWidth::Auto;Variants§
Fixed(u32)
Fixed width in pixels.
Each bar will have exactly the specified width regardless of the available space or number of data points. This provides consistent bar appearance but may cause bars to overlap or leave unused space.
§Examples
use embedded_charts::prelude::*;
let width = BarWidth::Fixed(25); // 25 pixels widePercentage(f32)
Percentage of available space per bar (0.0 to 1.0).
Each bar will occupy the specified percentage of the space allocated to it. For example, 0.8 means each bar uses 80% of its allocated space, leaving 20% for spacing.
§Examples
use embedded_charts::prelude::*;
let width = BarWidth::Percentage(0.7); // 70% of allocated spaceAuto
Automatic width calculation based on available space and data count.
The chart automatically calculates optimal bar width based on the viewport size, number of data points, and spacing requirements. This provides the best balance between bar visibility and spacing.
§Examples
use embedded_charts::prelude::*;
let width = BarWidth::Auto; // Automatic calculation