Struct Pie

Source
pub struct Pie {
    pub segs: Vec<PieSegment>,
    pub title: String,
    pub radius: f64,
}
Expand description
use graplot::Pie;
// without labels: let pie = Pie::new([35., 25., 25., 15.]);
let draw = [(35., "label"), (25., "len"), (25., "labeled"), (15., "test")];
let mut pie = Pie::new(draw);
pie.set_title("title");
pie.show();

Fields§

§segs: Vec<PieSegment>§title: String§radius: f64

Implementations§

Source§

impl Pie

Source

pub fn new<A: PieSegs>(args: A) -> Pie

Examples found in repository?
examples/pie_chart.rs (line 7)
4fn main() {
5    // without labels: let pie = Pie::new([35., 25., 25., 15.]);
6    let draw = [(35., "label"), (25., "len"), (25., "labeled"), (15., "test")];
7    let mut pie = Pie::new(draw);
8    pie.color(0, Color::new(0.6, 0.2, 0.3, 1.));
9    pie.show();
10}
Source

pub fn set_radius(&mut self, radius: f64)

sets the radius of the final circle. Default radius: 110.0

Source

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

Source

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

Colors the segment at the given index with the color. /// # Example

use graplot::{Pie, Color};
 
let mut pie = Pie::new([25., 20., 15., 15., 35.]);
pie.color(1, Color::new(0.2, 0.1, 0.3, 1.));
pie.show();
Examples found in repository?
examples/pie_chart.rs (line 8)
4fn main() {
5    // without labels: let pie = Pie::new([35., 25., 25., 15.]);
6    let draw = [(35., "label"), (25., "len"), (25., "labeled"), (15., "test")];
7    let mut pie = Pie::new(draw);
8    pie.color(0, Color::new(0.6, 0.2, 0.3, 1.));
9    pie.show();
10}
Source

pub fn show(self)

Examples found in repository?
examples/pie_chart.rs (line 9)
4fn main() {
5    // without labels: let pie = Pie::new([35., 25., 25., 15.]);
6    let draw = [(35., "label"), (25., "len"), (25., "labeled"), (15., "test")];
7    let mut pie = Pie::new(draw);
8    pie.color(0, Color::new(0.6, 0.2, 0.3, 1.));
9    pie.show();
10}

Trait Implementations§

Auto Trait Implementations§

§

impl Freeze for Pie

§

impl RefUnwindSafe for Pie

§

impl Send for Pie

§

impl Sync for Pie

§

impl Unpin for Pie

§

impl UnwindSafe for Pie

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.