pub struct BarChart { /* private fields */ }Expand description
A bar chart.
Implementations§
Source§impl BarChart
impl BarChart
Sourcepub fn new(bars: Vec<Bar>) -> BarChart
pub fn new(bars: Vec<Bar>) -> BarChart
Create a bar chart. It defaults to vertically oriented elements.
Sourcepub fn color(self, color: impl Into<Color32>) -> BarChart
pub fn color(self, color: impl Into<Color32>) -> BarChart
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) -> BarChart
pub fn name(self, name: impl ToString) -> BarChart
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) -> BarChart
pub fn vertical(self) -> BarChart
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) -> BarChart
pub fn horizontal(self) -> BarChart
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, &BarChart) -> String>,
) -> BarChart
pub fn element_formatter( self, formatter: Box<dyn Fn(&Bar, &BarChart) -> String>, ) -> BarChart
Add a custom way to format an element. Can be used to display a set number of decimals or custom labels.
Trait Implementations§
Source§impl PlotItem for BarChart
impl PlotItem for BarChart
fn shapes(&self, _ui: &Ui, transform: &PlotTransform, shapes: &mut Vec<Shape>)
Source§fn initialize(&mut self, _x_range: RangeInclusive<f64>)
fn initialize(&mut self, _x_range: RangeInclusive<f64>)
fn name(&self) -> &str
fn color(&self) -> Color32
fn highlight(&mut self)
fn highlighted(&self) -> bool
fn geometry(&self) -> PlotGeometry<'_>
fn bounds(&self) -> PlotBounds
fn find_closest( &self, point: Pos2, transform: &PlotTransform, ) -> Option<ClosestElem>
fn on_hover( &self, elem: ClosestElem, shapes: &mut Vec<Shape>, cursors: &mut Vec<Cursor>, plot: &PlotConfig<'_>, _: &Option<Box<dyn Fn(&str, &PlotPoint) -> String>>, )
fn id(&self) -> Option<Id>
Auto Trait Implementations§
impl Freeze for BarChart
impl !RefUnwindSafe for BarChart
impl !Send for BarChart
impl !Sync for BarChart
impl Unpin for BarChart
impl !UnwindSafe for BarChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more