load target image path from config

This commit is contained in:
Ondrej Novak 2026-06-19 23:27:45 +02:00
parent fe3cbc7fc3
commit 1d4e450c99
Signed by: handy
SSH Key Fingerprint: SHA256:jlNm8ijkaMl4X7+nn3zBFTJufdQgT4unKJoZVH6kYTM
3 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use crate::Container;
pub struct StackedConfig { pub struct StackedConfig {
pub name: String, pub name: String,
pub path: String,
pub width_px_per_sample: u32, pub width_px_per_sample: u32,
pub height_px: u32, pub height_px: u32,
pub series: Vec<StackedSeriesConfig>, pub series: Vec<StackedSeriesConfig>,

View File

@ -10,6 +10,7 @@ pub struct Config {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct GraphConfig { pub struct GraphConfig {
pub name: String, pub name: String,
pub path: String,
pub width_px: u16, pub width_px: u16,
pub height_px: u16, pub height_px: u16,
pub samples: u16, pub samples: u16,

View File

@ -18,6 +18,7 @@ impl Graph {
pub fn new(config: &GraphConfig, proto: &mut Protocol) -> Graph { pub fn new(config: &GraphConfig, proto: &mut Protocol) -> Graph {
let stacked_config = StackedConfig { let stacked_config = StackedConfig {
name: config.name.to_string(), name: config.name.to_string(),
path: config.path.to_string(),
height_px: config.height_px as u32, height_px: config.height_px as u32,
max_samples: config.samples as u32, max_samples: config.samples as u32,
width_px_per_sample: (config.width_px / config.samples) as u32, width_px_per_sample: (config.width_px / config.samples) as u32,
@ -90,7 +91,7 @@ impl Runner {
.map_err(|e| RunnerError::CouldNotGetData(e.to_string()))?; .map_err(|e| RunnerError::CouldNotGetData(e.to_string()))?;
g.series.push(sample); g.series.push(sample);
let img = stacked(&g.series); let img = stacked(&g.series);
img.save("cpu.png".to_string()) img.save(g.series.config.path.to_string())
.map_err(|e| RunnerError::CouldNotSaveImage(e.to_string()))?; .map_err(|e| RunnerError::CouldNotSaveImage(e.to_string()))?;
} }