Struct poloto::Plotter [−][src]
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]
&mut self,
name: impl ToString,
plots: I
)
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]
&mut self,
name: impl ToString,
plots: I
)
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]
&mut self,
name: impl ToString,
plots: I
)
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]
&mut self,
name: impl ToString,
plots: I
)
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]
self,
el: &mut Element<T>
) -> Result<&mut Element<T>, Error>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,