https://github.com/itslimenade/bonbon
A sweet and simple Rust library for generating static diabetes data visualizations.
https://github.com/itslimenade/bonbon
crate diabetes diabetes-dateset-analysis graph plotting rust
Last synced: 3 months ago
JSON representation
A sweet and simple Rust library for generating static diabetes data visualizations.
- Host: GitHub
- URL: https://github.com/itslimenade/bonbon
- Owner: ItsLimeNade
- License: mpl-2.0
- Created: 2026-01-17T11:07:15.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-05-04T08:29:14.000Z (3 months ago)
- Last Synced: 2026-05-04T09:46:11.525Z (3 months ago)
- Topics: crate, diabetes, diabetes-dateset-analysis, graph, plotting, rust
- Language: Rust
- Homepage: https://docs.rs/bonbon
- Size: 747 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Bonbon
A sweet and simple Rust library for generating static diabetes data visualizations.
---
## Overview
Bonbon is a fast, customizable graph rendering library designed for diabetes related data visualization. It supports glucose entries, insulin doses, carbohydrate intake, and manual blood glucose readings with configurable themes, units, and layout options.
## Features
- **High Performance**: Optimized rendering with parallel processing via Rayon
- **Flexible Units**: Support for mg/dL, mmol/L, or dual-unit display
- **Treatment Visualization**: Insulin boluses, carbohydrate entries, and manual BG readings
- **Customizable Themes**: Built-in dark & light themes with full customization support
- **Dynamic Scaling**: Automatic Y-axis scaling based on glucose values
- **Timezone Support**: Accurate time axis labels for any timezone
- **Microbolus Filtering**: Configurable threshold to simplify SMB visualization
- **BG Card**: Compact status card showing current glucose, trend, delta, IOB/COB, and a 3-hour sparkline
---
## Glucose Graph
The Glucose Graph is a full-resolution chart rendering glucose entries over time, with optional treatment markers (insulin boluses, carbs, manual BG readings), configurable Y-axis scaling, timezone-aware time axis, and dual-unit support.
---
## BG Card
The BG Card is a compact 640×320 status card (scalable via `with_scale`) that renders current glucose, trend arrow, delta, age, IOB/COB, and a color-coded 3-hour sparkline with an ambient gradient fill.
---
## Installation
Add Bonbon to your `Cargo.toml`:
```toml
[dependencies]
bonbon = "0.2"
```
## Examples & Docs
Some usage examples can be found in the `bonbon/examples` directory.
Additional documentation can be found on the `docs.rs` website.
## Performance Tips
To achieve the best possible rendering speed, it is highly recommended to compile with **native CPU optimizations**. This enables modern SIMD instructions (AVX2, NEON, etc.), which accelerates the pixel blending and sprite rendering operations.
You can enable this by setting the `RUSTFLAGS` environment variable:
```bash
RUSTFLAGS="-C target-cpu=native" cargo build --release
```
Or by adding a `.cargo/config.toml` to your project:
```TOML
[build]
rustflags = ["-C", "target-cpu=native"]
```
## Benchmarks
### BG Card build time at 4× scale (2560×1280)
Averaged across 8 rendering scenarios (InRange, High, Low, multi-status, mmol/L, flat sparkline, single point, no sparkline).
| Hardware | Avg. build time |
| --- | --- |
| **Ryzen 5 9600x** | ~25.3ms |
### Graph build time (using native CPU compilation optimizations)
| Benchmark Test | Resolution | Entries | Ryzen 5 9600x | Quad-core ARM Cortex-A72 |
| --- | --- | --- | --- | --- |
| **Standard FHD** | 1920x1080 | 288 | 2.26ms | 21.15ms |
| **QHD** | 2560x1440 | 288 | 2.95ms | 27.80ms |
| **UHD 4K** | 3840x2160 | 288 | 5.56ms | 59.26ms |
| **Extreme 8K** | 7680x4320 | 288 | 19.66ms | 218.67ms |
| **High Data Volume** | 1920x1080 | 8,640 | 34.62ms | 206.94ms |
## License
This project is licensed under the MPL-2.0 License. See the [LICENSE](LICENSE) file for details.