Code Monkey home page Code Monkey logo

rust-sparkline's Introduction

Sparklines for Rust

Build Status

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

$ 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=<min>] [--max=<max>] [--theme=<theme>] [--statline] <values>...
  sparkr [--min=<min>] [--max=<max>] [--theme=<theme>] [--statline]
  sparkr (-h | --help)
  sparkr --version

Options:
  -h --help       Show this screen.
  --version       Show version.
  --min=<min>     Specify minimum value instead of calculating it.
  --max=<max>     Specify maximum value instead of calculating it.
  --statline      Show a line of stats after the sparkline.
  --theme=<theme>   What theme to use, 'colour' or 'classic' (default).
  <values>        Just values.

library - sparkline

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.

rust-sparkline's People

Contributors

ferrouswheel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.