diff --git a/src/main.rs b/src/main.rs index 0a597e7..16f16b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,8 +96,8 @@ fn main() -> Result<(), Box> { // Parse data let toml_data = fs::read_to_string("data.toml").expect("Failed to read data file."); let data: Data = toml::from_str(&toml_data).expect("Failed to parse TOML data"); - let max_temp = data.max_temp() + 1.0; - let min_temp = data.min_temp() - 1.0; + let max_temp = f64::ceil((data.max_temp() + 1.0) / 5.0) * 5.0; + let min_temp = f64::floor((data.min_temp() - 1.0) / 5.0) * 5.0; let num_temps = data.len(); // Chart data @@ -125,6 +125,7 @@ fn main() -> Result<(), Box> { .y_desc("Temps (C)") .draw()?; + // CPU temp sensors data.temps.iter().for_each(|temps| { let color = line_colors.next(); chart @@ -186,13 +187,42 @@ fn main() -> Result<(), Box> { _ => {} }); + // Test dividers + data.tests + .iter() + .filter(|test| test.name != "Idle") + .for_each(|test| { + let color = match test.name.as_str() { + "Cooldown" => RGBAColor(0, 0, 255, 1.0), + "Prime95" => RGBAColor(255, 0, 0, 1.0), + "Sysbench" => RGBAColor(255, 165, 0, 1.0), + _ => line_colors.next().to_rgba(), + }; + test.offsets.iter().for_each(|offset| { + let offset = *offset as i32; + chart + .draw_series(DashedLineSeries::new( + [(offset, min_temp + 1.0), (offset, max_temp - 1.0)], + 10, + 5, + ShapeStyle { + color, + filled: false, + stroke_width: 1, + }, + )) + .unwrap(); + }); + }); + + // Export to file chart .configure_series_labels() .position(SeriesLabelPosition::LowerRight) .margin(20) .legend_area_size(5) .border_style(BLACK) - .background_style(BLACK.mix(0.1)) + .background_style(RGBColor(192, 192, 192)) .label_font(("Calibri", 20)) .draw()?;