simple-chart

Crates.iosimple-chart
lib.rssimple-chart
version0.7.9
sourcesrc
created_at2016-09-28 08:36:17.810914
updated_at2016-10-27 11:16:43.737262
descriptionSimple line chart in bmp format.
homepagehttps://github.com/serejkaaa512/simple-chart.git
repositoryhttps://github.com/serejkaaa512/simple-chart.git
max_upload_size
id6651
size978,648
(serejkaaa512)

documentation

http://serejkaaa512.github.io/simple-chart/

README

Simple Chart

This repository contains stuff to represent iterator of (T, T), that is convertable to (f64,f64), as line chart in bmp format.

Build Status

Example 1. One serie and auto calculated axis returned as Vec<u8>:

    let mut chart = Chart::new(200, 100, "#ffffff", "#000000")
        .unwrap();

    let v: Vec<_> = vec![(1.2,2.3), (3.4, 4.5), (5.6, 6.7)];
    let serie = Serie::new(v.into_iter(), "#ff0000").unwrap();
    let series = vec![serie];
    
    let bmp = chart.draw(series.into_iter());

chart1

Example 2. One serie, calculated from included macros formula!,

and manual setted axis x:

    let mut chart = Chart::new(400, 500, "#f14500", "#0027ff")
        .unwrap()
        .add_axis_x(Axis::new(-2.0, 2.0, 7, 2));

    let v = formula!(y(x) = x.sin(), x = [-3.14, 3.14; 0.1]);
    let serie = Serie::new(v.into_iter(), "#ffff00").unwrap();
    let series = vec![serie];

    let bmp = chart.draw(series.into_iter());

chart2

Example 3. Two series and manual setted axis x and y:

    let mut chart = Chart::new(740, 480, "#000000", "#ffffff")
        .unwrap()
        .add_axis_x(Axis::new(-2.0, 2.0, 7, 2))
        .add_axis_y(Axis::new(-2.0, 2.0, 7, 2));

    let v1 = formula!(y(x) = x.sin(), x = [-3.14, 3.14; 0.1]);
    let v2 = formula!(y(x) = x.cos(), x = [-3.14, 3.14; 0.1]);
    let serie1 = Serie::new(v1.into_iter(), "#ff0000").unwrap();
    let serie2 = Serie::new(v2.into_iter(), "#00ff00").unwrap();
    let series = vec![serie1, serie2];

    let bmp = chart.draw(series.into_iter());

chart3

Usage

Put this in your Cargo.toml:

[dependencies]
simple-chart = "*"

And this in your crate root:

extern crate simple_chart;
use simple_chart::{Chart, Serie, Axis, Point};

Resources

License

MIT

Commit count: 58

cargo fmt