Struct Bar

Source
pub struct Bar {
    pub bars: Vec<BarDesc>,
    pub ys: Vec<f64>,
    pub axis_desc: AxisDesc,
    pub desc: Desc,
}
Expand description
use graplot::Bar;
 
let mut bar = Bar::new(["Ferris", "Stefan", "Test"], &[100., 200., 700.]);
bar.set_title("title");
bar.set_xlabel("test");
bar.show();

Fields§

§bars: Vec<BarDesc>§ys: Vec<f64>§axis_desc: AxisDesc§desc: Desc

Implementations§

Source§

impl Bar

Source

pub fn new<A: BarDescArg>(xs: A, ys: &[f64]) -> Bar

Examples found in repository?
examples/bar.rs (line 4)
3fn main() {
4    let mut bar = Bar::new(["Ferris", "Stefan", "Test"], &[100., 200., 700.]);
5    bar.set_title("title");
6    bar.set_xlabel("test");
7    bar.show();
8}
More examples
Hide additional examples
examples/bar_colored.rs (line 4)
3fn main() {
4    let mut bar = Bar::new([("Ferris", RED), ("Stefan", GREEN), ("Test", BLUE)], &[100., 200., 500.,]);
5    bar.add(("Added", ORANGE), 400.);
6    bar.set_title("title");
7    bar.set_ylabel("test");
8    bar.show();
9}
Source

pub fn set_title(&mut self, title: &str)

Examples found in repository?
examples/bar.rs (line 5)
3fn main() {
4    let mut bar = Bar::new(["Ferris", "Stefan", "Test"], &[100., 200., 700.]);
5    bar.set_title("title");
6    bar.set_xlabel("test");
7    bar.show();
8}
More examples
Hide additional examples
examples/bar_colored.rs (line 6)
3fn main() {
4    let mut bar = Bar::new([("Ferris", RED), ("Stefan", GREEN), ("Test", BLUE)], &[100., 200., 500.,]);
5    bar.add(("Added", ORANGE), 400.);
6    bar.set_title("title");
7    bar.set_ylabel("test");
8    bar.show();
9}
Source

pub fn set_xlabel(&mut self, label: &str)

Examples found in repository?
examples/bar.rs (line 6)
3fn main() {
4    let mut bar = Bar::new(["Ferris", "Stefan", "Test"], &[100., 200., 700.]);
5    bar.set_title("title");
6    bar.set_xlabel("test");
7    bar.show();
8}
Source

pub fn set_ylabel(&mut self, label: &str)

Examples found in repository?
examples/bar_colored.rs (line 7)
3fn main() {
4    let mut bar = Bar::new([("Ferris", RED), ("Stefan", GREEN), ("Test", BLUE)], &[100., 200., 500.,]);
5    bar.add(("Added", ORANGE), 400.);
6    bar.set_title("title");
7    bar.set_ylabel("test");
8    bar.show();
9}
Source

pub fn color(&mut self, idx: usize, color: Color)

Colors the bar at the given index with the color.

use graplot::{Bar, Color};
 
let mut bar = Bar::new(["Red", "Green", "Blue"], &[200., 220., 250.]);
bar.color(0, Color::new(1., 0., 0., 1.,));
bar.color(2, Color::new(0., 0., 1., 1.,));
bar.show();
Source

pub fn add<A: BarDescArg>(&mut self, bar: A, y: f64)

Examples found in repository?
examples/bar_colored.rs (line 5)
3fn main() {
4    let mut bar = Bar::new([("Ferris", RED), ("Stefan", GREEN), ("Test", BLUE)], &[100., 200., 500.,]);
5    bar.add(("Added", ORANGE), 400.);
6    bar.set_title("title");
7    bar.set_ylabel("test");
8    bar.show();
9}
Source

pub fn show(self)

Examples found in repository?
examples/bar.rs (line 7)
3fn main() {
4    let mut bar = Bar::new(["Ferris", "Stefan", "Test"], &[100., 200., 700.]);
5    bar.set_title("title");
6    bar.set_xlabel("test");
7    bar.show();
8}
More examples
Hide additional examples
examples/bar_colored.rs (line 8)
3fn main() {
4    let mut bar = Bar::new([("Ferris", RED), ("Stefan", GREEN), ("Test", BLUE)], &[100., 200., 500.,]);
5    bar.add(("Added", ORANGE), 400.);
6    bar.set_title("title");
7    bar.set_ylabel("test");
8    bar.show();
9}

Auto Trait Implementations§

§

impl Freeze for Bar

§

impl RefUnwindSafe for Bar

§

impl Send for Bar

§

impl Sync for Bar

§

impl Unpin for Bar

§

impl UnwindSafe for Bar

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.