Switch to PNG output

This commit is contained in:
2Shirt 2025-07-05 20:43:40 -07:00
parent 7af40ef00b
commit cb3eb2876c
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 14 additions and 13 deletions

20
Cargo.lock generated
View file

@ -318,16 +318,6 @@ version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
[[package]]
name = "hmm"
version = "0.1.0"
dependencies = [
"chrono",
"plotters",
"serde",
"toml",
]
[[package]]
name = "iana-time-zone"
version = "0.1.63"
@ -1065,6 +1055,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "wk-cpu-graph"
version = "0.1.0"
dependencies = [
"chrono",
"plotters",
"serde",
"toml",
]
[[package]]
name = "yeslogic-fontconfig-sys"
version = "6.0.0"

View file

@ -90,7 +90,8 @@ struct Averages {
temp: f64,
}
const OUT_FILE_NAME: &str = "hmm.svg";
//const OUT_FILE_NAME: &str = "hmm.svg";
const OUT_FILE_NAME: &str = "hmm.png"; // TODO: Switch to SVG
fn main() -> Result<(), Box<dyn Error>> {
// Parse data
let toml_data = fs::read_to_string("data.toml").expect("Failed to read data file.");
@ -101,7 +102,8 @@ fn main() -> Result<(), Box<dyn Error>> {
// Chart data
let mut line_colors = LineColors::new();
let root = SVGBackend::new(OUT_FILE_NAME, (1600, 900)).into_drawing_area();
//let root = SVGBackend::new(OUT_FILE_NAME, (1600, 900)).into_drawing_area();
let root = BitMapBackend::new(OUT_FILE_NAME, (1600, 900)).into_drawing_area();
root.fill(&WHITE)?;
@ -193,7 +195,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.background_style(BLACK.mix(0.1))
.label_font(("Calibri", 20))
.draw()?;
println!("File exported?");
// To avoid the IO failure being ignored silently, we manually call the present function
root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");