use bonbon::prelude::*;
use chrono::{Duration, Utc};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let now = Utc::now();
let entries = vec![
GraphEntry {
sgv: 110.0,
date: now - Duration::minutes(30),
},
GraphEntry {
sgv: 145.0,
date: now - Duration::minutes(15),
},
GraphEntry {
sgv: 185.0,
date: now,
},
];
let treatments = vec![GraphTreatment {
insulin: Some(2.5),
carbs: Some(30.0),
mbg: None,
date: now - Duration::minutes(45),
is_isf: false,
}];
let layout = LayoutConfig {
width: 1280,
height: 720,
..Default::default()
};
let image = GlucoseGraphBuilder::new()
.with_layout(layout)
.with_theme(Theme::dark())
.with_units(UnitDisplay::MgDl)
.with_targets(70.0, 180.0)
.with_entries(entries)
.with_treatments(treatments)
.with_time_axis(TimeAxisMode::EquallyDistributed { count: 6 })
.build()?;
image.save("glucose_report.png")?;
Ok(())
}