josie / alder-tools

Graphs: 2/3 viewport height (cores compress to 1/3), flat-step glyphs (no rounded corners) for peak visibility

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

parents: d9c227b

diff --git a/src/plot.rs b/src/plot.rs
index 225482a..b750cb4 100644
--- a/src/plot.rs
+++ b/src/plot.rs
@@ -58,19 +58,6 @@ fn levels(samples: &[f64], max: f64, rows: usize) -> Vec<usize> {
         .collect()
 }
 
-/// nvtop corner convention for one column where the level steps from
-/// `prev` to `now` (row numbers; smaller = higher on screen):
-/// falling value (line steps down screen): `╮` at prev (open left,
-/// toward the incoming line) + `╰` at now (open right, toward the
-/// outgoing line); rising value: `╭` at now + `╯` at prev.
-fn step_glyphs(prev: usize, now: usize) -> (usize, usize, char, char) {
-    if prev < now {
-        (prev, now, '╮', '╰') // falling on screen
-    } else {
-        (now, prev, '╭', '╯') // rising on screen
-    }
-}
-
 pub fn render(f: &mut Frame, area: Rect, ring: &Ring, window_ticks: usize, max: f64, color: Color, marker_row: Option<u16>) {
     if area.width == 0 || area.height == 0 || max <= 0.0 {
         return;
@@ -109,16 +96,11 @@ pub fn render(f: &mut Frame, area: Rect, ring: &Ring, window_ticks: usize, max:
         if prev_l == l {
             set(l, c, '─', st);
         } else {
-            // nvtop corner convention: a step connects the previous row
-            // (open side toward the incoming line) to the new row (open
-            // side toward the outgoing line).
-            //   falling value = line steps DOWN screen (prev above, new
-            //   below): top cell '╮' opens left, bottom cell '╭' opens
-            //   right. Rising value (line steps UP screen): top '╭',
-            //   bottom '╯'.
-            let (top, bot, top_ch, bot_ch) = step_glyphs(prev_l, l);
-            set(top, c, top_ch, st);
-            set(bot, c, bot_ch, st);
+            // Flat-step style (no rounded corners — they masked peaks):
+            // both stepped rows get level dashes, verticals between.
+            let (top, bot) = if prev_l < l { (prev_l, l) } else { (l, prev_l) };
+            set(top, c, '─', st);
+            set(bot, c, '─', st);
             for r in top + 1..bot {
                 set(r, c, '│', st);
             }
@@ -156,14 +138,6 @@ mod tests {
         assert_eq!(levels(&[5.0], 10.0, 5), [2]);
     }
 
-    #[test]
-    fn falling_step_uses_drop_glyphs() {
-        // prev row 1, now row 3 = value fell -> '╮' top, '╰' bottom
-        assert_eq!(step_glyphs(1, 3), (1, 3, '╮', '╰'));
-        // prev row 3, now row 1 = value rose -> '╭' top, '╯' bottom
-        assert_eq!(step_glyphs(3, 1), (1, 3, '╭', '╯'));
-    }
-
     #[test]
     fn ring_window_and_wrap() {
         let mut r = Ring::new(4);
diff --git a/src/ui.rs b/src/ui.rs
index 2e32cdf..88e8d52 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -24,8 +24,6 @@ const SCALE_MARGIN: f64 = 0.05;
 /// Temp bar scale, °C.
 const TEMP_BAR_MAX: f64 = 100.0;
 /// Graph rows in the package zone (below each caption line).
-const GRAPH_ROWS: u16 = 5;
-/// Below this width the package zone falls back to meter rows (no graphs).
 const GRAPHS_MIN_WIDTH: u16 = 70;
 /// Width at/below which core sections stack to one column.
 const DUAL_COLUMN_MIN_WIDTH: u16 = 100;
@@ -418,10 +416,18 @@ pub fn draw(f: &mut Frame, app: &App) {
         config::Layout::Auto => w >= DUAL_COLUMN_MIN_WIDTH,
     };
 
-    // ---- vertical budget: cores zone flexes, package zone fixed, footer 1
+    // ---- vertical budget: graphs get 2/3 of the height, cores 1/3 ----
     let footer_h = 1u16;
-    let bottom_h: u16 = if app.cfg.graphs && w >= GRAPHS_MIN_WIDTH {
-        GRAPH_ROWS + 1 // caption line above each 5-row graph
+    let graph_rows: u16 = if app.cfg.graphs && w >= GRAPHS_MIN_WIDTH {
+        // 2/3 of rows minus caption + separator, floored at 3 rows.
+        ((area.height * 2 / 3)
+            .saturating_sub(2))
+            .max(3)
+    } else {
+        0
+    };
+    let bottom_h: u16 = if graph_rows > 0 {
+        graph_rows + 1 // caption line above the graph
     } else {
         2 // pkg power + pkg temp meter rows
     };
@@ -480,7 +486,7 @@ pub fn draw(f: &mut Frame, app: &App) {
         let watt_graph_max = ring_max(&app.watts_graph, 10.0);
         for (i, (label, text, ring, max, color, marker)) in [
             ("vCore", hero_text.clone(), &app.vcore_graph, vc_graph_max, vc_color,
-                Some(((1.0 - (app.cfg.vcore_limit / vc_graph_max).clamp(0.0, 1.0)) * (GRAPH_ROWS - 1) as f64).round() as u16)),
+                Some(((1.0 - (app.cfg.vcore_limit / vc_graph_max).clamp(0.0, 1.0)) * (graph_rows - 1) as f64).round() as u16)),
             ("Pkg power", fmt_opt_watts(app.package_watts), &app.watts_graph, watt_graph_max, Color::Blue, None),
             ("Pkg temp", fmt_opt_temp(app.package_temp), &app.temp_graph,
                 ring_max(&app.temp_graph, 0.0).max(50.0),
@@ -494,7 +500,7 @@ pub fn draw(f: &mut Frame, app: &App) {
                 Span::styled(text, Style::default().add_modifier(Modifier::BOLD)),
             ]);
             f.render_widget(ratatui::text::Text::from(caption), Rect { height: 1, ..rect });
-            plot::render(f, Rect { y: rect.y + 1, height: GRAPH_ROWS, ..rect }, ring, ticks, max, color, marker);
+            plot::render(f, Rect { y: rect.y + 1, height: graph_rows, ..rect }, ring, ticks, max, color, marker);
             x += thirds;
         }
     } else {