I needed a project to learn Rust. This is it!
Inspired by https://github.com/holman/spark and https://gist.github.com/stefanv/1371985
This provides a Rust library sparkline
and executable sparkr
.
``` $ sparkr --theme classic --min -10 2 4 0 3 9 10 8 2 5 6 ▅ ▆ ▅ ▆ █ █ █ ▅ ▇ ▇ $ sparkr --statline --theme colour 2 4 0 3 9 10 8 2 5 6 ▂ ▄ ▁ ▃ █ █ ▇ ▂ ▅ ▅ min: 0, max: 10, range: 10 $ sparkr -h sparkr
Usage:
sparkr [--min=
Options:
-h --help Show this screen.
--version Show version.
--min=
Add this to your Cargo.toml
:
[dependencies]
sparkline=0.1
This takes a vec of numbers and prints out a sparkline: ``` extern crate sparkline; use sparkline::*;
let (min, max) : (f64, f64) = (0.0, 10.0); let values = vec![2.0, 3.0, 2.0, 6.0, 9.0]; let sparky = select_sparkline(SparkThemeName::Colour); for num in values.iter() { let s : &String = sparky.spark(min, max, *num); print!("{} ", s); }
```
Currently the library expects values to be f64
.