[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![Build Status][build-status]][build-status-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url]
Embedded graphics logo

Sparklines for Rust's Embedded-graphics

Visual demo on simulator

Sparklines are small, high resolution graphics embedded in a context of words, numbers or images". Edward Tufte describes sparklines as "data-intense, design-simple, word-sized graphics".
Explore the docs »

Rust Crate · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Quickstart
  4. Roadmap
  5. License
  6. Contact
  7. Acknowledgments
## About The Project This library is a Rust implementation of [ESParklines](https://github.com/0xPIT/ESParklines) library which is extemely useful for creating real-time graphs for use with small embedded systems screeens. This library is designed to be as simple as possible. It is responsible for: - holding a buffer of pre-defined size of numeric data type - renders sparklines using a passed-in function to draw lines - is display-driver independent as you can provide any drawing function - works with embedded-graphics simulator so you can quickly iterate on you dev machine

(back to top)

### Built With * [rust](https://www.rust-lang.org/) * [embedded-graphics](https://github.com/embedded-graphics/embedded-graphics) * [embedded-graphics-simulator](https://docs.rs/embedded-graphics-simulator/latest/embedded_graphics_simulator/)

(back to top)

## Getting Started Make sure you have your `rust` environment configurated ### Installation 1. Add library to your `Cargo.toml` ```toml ... [dependencies] embedded-graphics-sparklines = "0.1.0" ``` 2. Use the library in you code ```rust let mut display: SimulatorDisplay = SimulatorDisplay::new(Size::new(240, 135)); let bbox = Rectangle::new(Point::new(0, 26), Size::new(240, 90)); let draw_fn = |lastp, p| Line::new(lastp, p); // create sparkline object let mut sparkline = Sparkline::new( bbox, // position and size of the sparkline 32, // max samples to store in memory (and display on graph) BinaryColor::On, 1, // stroke size draw_fn, ); let output_settings = OutputSettingsBuilder::new() .theme(BinaryColorTheme::OledBlue) .build(); let mut window = Window::new("Sparkline", &output_settings); loop { let val = rand::thread_rng().gen_range(0..100); sparkline.add(val); sparkline.draw(&mut display)?; window.update(&display); thread::sleep( Duration::from_millis(100); } ``` 3. Experiment and have fun! :relieved: See `main.rs` if you want to run a quick demo.

(back to top)

## Quickstart 1. Make sure you've got `cargo` set up 2. Install cargo binary crate to be able to test easily on your computer ```bash $ cargo install embedded-graphics-sparklines ``` 2. Run the provided binary example with simulator display ```bash $ embedded-graphics-sparklines --features build-binary ``` 3. You should see an output similar to the followig one ![demo screenshot](./assets/demo-screenshot.png)

(back to top)

## Roadmap - [x] add tests - [x] add rustdocs - [ ] CI integration with GithHub Actions - [ ] better error generation & handling See the [open issues](https://github.com/bernii/embedded-graphics-sparklines/issues) for a full list of proposed features (and known issues).

(back to top)

## License Distributed under the MIT License. See `LICENSE` for more information.

(back to top)

## Contact Bernard Kobos - [@bkobos](https://twitter.com/bkobos) - bkobos@gmail.com Project Link: [https://github.com/bernii/embedded-graphics-sparklines](https://github.com/bernii/embedded-graphics-sparklines)

(back to top)

## Acknowledgments * ESParklines [project](https://github.com/0xPIT/ESParklines) which this is based on

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/bernii/embedded-graphics-sparklines.svg?style=for-the-badge [contributors-url]: https://github.com/bernii/embedded-graphics-sparklines/graphs/contributors [forks-shield]: https://img.shields.io/github/forks/bernii/embedded-graphics-sparklines.svg?style=for-the-badge [forks-url]: https://github.com/bernii/embedded-graphics-sparklines/network/members [stars-shield]: https://img.shields.io/github/stars/bernii/embedded-graphics-sparklines.svg?style=for-the-badge [stars-url]: https://github.com/bernii/embedded-graphics-sparklines/stargazers [issues-shield]: https://img.shields.io/github/issues/bernii/embedded-graphics-sparklines.svg?style=for-the-badge [issues-url]: https://github.com/bernii/embedded-graphics-sparklines/issues [license-shield]: https://img.shields.io/github/license/bernii/embedded-graphics-sparklines.svg?style=for-the-badge [license-url]: https://github.com/bernii/embedded-graphics-sparklines/blob/main/LICENSE [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 [linkedin-url]: https://linkedin.com/in/bernii [product-screenshot]: images/screenshot.png [build-status]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbernii%2Fembedded-graphics-sparklines%2Fbadge%3Fref%3Dmain&style=for-the-badge [build-status-url]: https://actions-badge.atrox.dev/bernii/embedded-graphics-sparklines/goto?ref=main