This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0eec94759e404520d68c251a8a2236aaff875ea8
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 3 19:28:37 2026 +0200

    CAMEL-23831: Use stacked colors in heap chart bars in camel-tui
    
    Green at bottom (<60%), yellow in middle (60-80%), light red at top (>80%)
    so each bar visually shows the severity zones of heap usage.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/MemoryTab.java     | 28 +++++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MemoryTab.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MemoryTab.java
index a269e1576d51..3081c54bff79 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MemoryTab.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MemoryTab.java
@@ -288,18 +288,18 @@ class MemoryTab extends AbstractTab {
             data[dataOffset + (i - startIdx)] = hist.get(i);
         }
 
-        // Render multi-row bar chart with per-column color based on heap load 
at that point
+        // Render multi-row bar chart with stacked colors: green (<60%), 
yellow (60-80%), light red (>80%)
         Buffer buf = frame.buffer();
+        // Precompute eighths thresholds for the color bands
+        int greenEighths = (int) Math.round(0.6 * chartH * 8.0);
+        int yellowEighths = (int) Math.round(0.8 * chartH * 8.0);
+        Style greenStyle = Style.EMPTY.fg(Color.GREEN);
+        Style yellowStyle = Style.EMPTY.fg(Color.YELLOW);
+        Style redStyle = Style.EMPTY.fg(Color.LIGHT_RED);
 
         for (int col = 0; col < chartW; col++) {
-            long colPct = ceiling > 0 ? data[col] * 100 / ceiling : 0;
-            Color colColor = colPct >= 80 ? Color.LIGHT_RED : colPct >= 60 ? 
Color.YELLOW : Color.GREEN;
-            Style colStyle = Style.EMPTY.fg(colColor);
-
             double ratio = (double) data[col] / ceiling;
-            // Total eighths this column fills (chartH rows * 8 eighths per 
row)
-            double fillEighths = ratio * chartH * 8.0;
-            int totalEighths = (int) Math.round(fillEighths);
+            int totalEighths = (int) Math.round(ratio * chartH * 8.0);
 
             // Render from bottom to top
             for (int row = 0; row < chartH; row++) {
@@ -307,7 +307,17 @@ class MemoryTab extends AbstractTab {
                 int x = inner.x() + col;
                 int rowEighths = Math.min(8, Math.max(0, totalEighths - row * 
8));
                 if (rowEighths > 0) {
-                    buf.setString(x, y, BAR_EIGHTHS[rowEighths], colStyle);
+                    // Determine color based on vertical position in the bar
+                    int eighthsAtRowBottom = row * 8;
+                    Style style;
+                    if (eighthsAtRowBottom >= yellowEighths) {
+                        style = redStyle;
+                    } else if (eighthsAtRowBottom >= greenEighths) {
+                        style = yellowStyle;
+                    } else {
+                        style = greenStyle;
+                    }
+                    buf.setString(x, y, BAR_EIGHTHS[rowEighths], style);
                 }
             }
         }

Reply via email to