josie / alder-tools

Plot: bucket window across width (mean per column) — full graph_secs honored, per-tick jitter smoothed

3cbad5061a1db90b51d7a064f3760473e904d502
josie <administrator@josie-c.com> · 2026-08-30T13:27 · browse files at this commit

parents: ca8702a

diff --git a/adlermon.conf b/adlermon.conf
index 00e386b..56ee7df 100644
--- a/adlermon.conf
+++ b/adlermon.conf
@@ -29,3 +29,10 @@ rail.in11.hide  = true
 rail.in12.label = Fixed 1.14
 rail.in13.hide  = true
 rail.in14.label = Fixed 1.5V
+poll_ms = 250
+graph_secs = 3600
+graphs = true
+layout = auto
+vcore_limit = 1.403
+temp_warn = 80.0
+temp_crit = 95.0
diff --git a/src/plot.rs b/src/plot.rs
index c7cad8b..2ef0aa8 100644
--- a/src/plot.rs
+++ b/src/plot.rs
@@ -65,8 +65,23 @@ pub fn render(f: &mut Frame, area: Rect, ring: &Ring, window_ticks: usize, max:
     let rows = area.height as usize;
     let cols = area.width as usize;
     let samples: Vec<f64> = ring.samples_window(window_ticks).collect();
-    let skip = samples.len().saturating_sub(cols);
-    let lvls = levels(&samples[skip..], max, rows);
+    if samples.is_empty() {
+        return;
+    }
+    // Bucket the window across the plot width (mean per column): the whole
+    // graph_secs window maps to `cols` columns, and per-tick jitter within
+    // a bucket averages out instead of drawing corner squiggles.
+    let per_col = samples.len() / cols;
+    let shown: Vec<f64> = if per_col >= 2 {
+        samples
+            .chunks(samples.len().div_ceil(cols))
+            .map(|b| b.iter().sum::<f64>() / b.len() as f64)
+            .collect()
+    } else {
+        samples
+    };
+    let skip = shown.len().saturating_sub(cols);
+    let lvls = levels(&shown[skip..], max, rows);
 
     let mut buf = vec![vec![(' ', Style::default()); cols]; rows];
     let mut set = |r: usize, c: usize, ch: char, st: Style| {