Add test dividers to CPU graph
This commit is contained in:
parent
cb3eb2876c
commit
b0748f370b
1 changed files with 33 additions and 3 deletions
36
src/main.rs
36
src/main.rs
|
|
@ -96,8 +96,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
// 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<dyn Error>> {
|
|||
.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<dyn Error>> {
|
|||
_ => {}
|
||||
});
|
||||
|
||||
// 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()?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue