pub struct BarArtist {
pub categories: Categories,
pub heights: Series,
pub color: Color,
pub label: Option<String>,
pub alpha: f64,
pub horizontal: bool,
pub bar_width: f64,
}Expand description
A bar chart rendering vertical or horizontal bars over categorical data.
Categories are placed at integer positions 0, 1, 2, ... on the
category axis, with each bar centered on its position. The bar_width
field controls the fraction of the inter-category spacing that the bar
occupies (1.0 = bars touching, 0.5 = half-width with gaps).
Fields§
§categories: CategoriesCategory labels for the bar axis.
heights: SeriesBar heights (or lengths, for horizontal bars).
color: ColorFill color of the bars.
label: Option<String>Optional legend label. When Some, the bar series appears in the legend.
alpha: f64Opacity from 0.0 (fully transparent) to 1.0 (fully opaque).
horizontal: boolWhen true, bars extend horizontally (categories on the y-axis).
bar_width: f64Bar width as a fraction of the category spacing (0.0, 1.0].
Implementations§
Source§impl BarArtist
impl BarArtist
Sourcepub fn data_bounds(&self) -> (f64, f64, f64, f64)
pub fn data_bounds(&self) -> (f64, f64, f64, f64)
Computes the data-space bounding box (xmin, xmax, ymin, ymax).
For vertical bars, the x-axis spans from -0.5 to n - 0.5 (where
n is the number of categories) so that bars are centered on integer
positions. The y-axis spans from 0.0 to the tallest bar, with a
fallback of (0.0, 1.0) when the heights series is empty.
For horizontal bars the axes are transposed: the y-axis holds the category positions and the x-axis holds the bar lengths.
Source§impl BarArtist
impl BarArtist
Sourcepub fn label(&mut self, label: &str) -> &mut Self
pub fn label(&mut self, label: &str) -> &mut Self
Sets the legend label.
When a legend is displayed on the figure, this label will appear next to the color swatch for this bar series. Passing a new value overwrites any previously set label.
§Arguments
label- A string slice that will be stored as the legend entry.
Sourcepub fn alpha(&mut self, alpha: f64) -> &mut Self
pub fn alpha(&mut self, alpha: f64) -> &mut Self
Sets the opacity.
The value is clamped to the range [0.0, 1.0], where 0.0 is fully
transparent and 1.0 is fully opaque.
§Arguments
alpha- The desired opacity level.
Sourcepub fn bar_width(&mut self, width: f64) -> &mut Self
pub fn bar_width(&mut self, width: f64) -> &mut Self
Sets the bar width as a fraction of the category spacing (0.0 to 1.0).
Smaller values produce thinner bars with more whitespace between them,
while larger values make the bars wider. The value is clamped to the
range [0.1, 1.0] so that bars are never invisibly thin nor overlap
their neighbours.
§Arguments
width- The fraction of available category space each bar should occupy.