Struct poloto::Plotter[][src]

pub struct Plotter<'a> { /* fields omitted */ }

Keeps track of plots. User supplies iterators that will be iterated on when render is called.

Implementations

impl<'a> Plotter<'a>[src]

pub fn new(title: &'a str, xname: &'a str, yname: &'a str) -> Plotter<'a>[src]

Create a plotter

Example

let plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");

pub fn line<I: IntoIterator<Item = [f64; 2]> + 'a>(
    &mut self,
    name: impl ToString,
    plots: I
)
[src]

Create a line from plots.

Example

let data=[
        [1.0f64,4.0],
        [2.0,5.0],
        [3.0,6.0]
];
let mut plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");
plotter.line("cow",data.iter().map(|&x|x))

pub fn line_fill<I: IntoIterator<Item = [f64; 2]> + 'a>(
    &mut self,
    name: impl ToString,
    plots: I
)
[src]

Create a line from plots that will be filled underneath.

Example

let data=[
        [1.0f64,4.0],
        [2.0,5.0],
        [3.0,6.0]
];
let mut plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");
plotter.line_fill("cow",data.iter().map(|&x|x))

pub fn scatter<I: IntoIterator<Item = [f64; 2]> + 'a>(
    &mut self,
    name: impl ToString,
    plots: I
)
[src]

Create a scatter plot from plots.

Example

let data=[
        [1.0f64,4.0],
        [2.0,5.0],
        [3.0,6.0]
];
let mut plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");
plotter.scatter("cow",data.iter().map(|&x|x))

pub fn histogram<I: IntoIterator<Item = [f64; 2]> + 'a>(
    &mut self,
    name: impl ToString,
    plots: I
)
[src]

Create a histogram from plots. Each bar's left side will line up with a point

Example

let data=[
        [1.0f64,4.0],
        [2.0,5.0],
        [3.0,6.0]
];
let mut plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");
plotter.histogram("cow",data.iter().map(|&x|x))

pub fn render<T: Write>(
    self,
    el: &mut Element<T>
) -> Result<&mut Element<T>, Error>
[src]

You can override the css in regular html if you embed the generated svg. This gives you a lot of flexibility giving your the power to dynamically change the theme of your svg.

However, if you want to embed the svg as an image, you lose this ability. If embedding as IMG is desired, instead the user can insert a custom style into the generated svg itself.

All the plot functions don't actually add anything to the document until a render function is called. So calls to this will append elements to the start of the document.

Example

fn main()->std::fmt::Result{
    use tagger::prelude::*;
    let data=[
        [1.0f64,4.0],
        [2.0,5.0],
        [3.0,6.0]
    ];
    let mut plotter = poloto::Plotter::new("Number of Cows per Year","Year","Cow");
    plotter.line("cow",data.iter().map(|&x|x));

    let mut buffer=String::new();
    let mut root=tagger::Element::new(&mut buffer);

    root.elem("svg",|writer|{
        let svg=writer.write(|w|{
            poloto::default_svg_tag::default()(w)?;
            Ok(w)
        })?;

        // Make the line purple.
        svg.elem_no_attr("style",|w|{
            write_ret!(w,"{}","<style>.poloto{--poloto_color0:purple;}</style>")
        })?;
    
        plotter.render(svg)
    })?;
    println!("{}",buffer);
    Ok(())
}

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Plotter<'a>

impl<'a> !Send for Plotter<'a>

impl<'a> !Sync for Plotter<'a>

impl<'a> Unpin for Plotter<'a>

impl<'a> !UnwindSafe for Plotter<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.