pub struct BarChart { /* private fields */ }Expand description
A bar chart.
Implementations§
source§impl BarChart
impl BarChart
sourcepub fn new(bars: Vec<Bar>) -> Self
pub fn new(bars: Vec<Bar>) -> Self
Create a bar chart. It defaults to vertically oriented elements.
sourcepub fn color(self, color: impl Into<Color32>) -> Self
pub fn color(self, color: impl Into<Color32>) -> Self
Set the default color. It is set on all elements that do not already have a specific color.
This is the color that shows up in the legend.
It can be overridden at the bar level (see [Bar]).
Default is Color32::TRANSPARENT which means a color will be auto-assigned.
sourcepub fn name(self, name: impl ToString) -> Self
pub fn name(self, name: impl ToString) -> Self
Name of this chart.
This name will show up in the plot legend, if legends are turned on. Multiple charts may share the same name, in which case they will also share an entry in the legend.
sourcepub fn vertical(self) -> Self
pub fn vertical(self) -> Self
Set all elements to be in a vertical orientation. Argument axis will be X and bar values will be on the Y axis.
sourcepub fn horizontal(self) -> Self
pub fn horizontal(self) -> Self
Set all elements to be in a horizontal orientation. Argument axis will be Y and bar values will be on the X axis.
sourcepub fn element_formatter(
self,
formatter: Box<dyn Fn(&Bar, &Self) -> String>
) -> Self
pub fn element_formatter( self, formatter: Box<dyn Fn(&Bar, &Self) -> String> ) -> Self
Add a custom way to format an element. Can be used to display a set number of decimals or custom labels.