[rhmessaging-commits] rhmessaging commits: r1556 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Sun Jan 13 13:57:33 EST 2008


Author: justi9
Date: 2008-01-13 13:57:33 -0500 (Sun, 13 Jan 2008)
New Revision: 1556

Modified:
   mgmt/cumin/python/cumin/charts.py
   mgmt/cumin/python/cumin/stat.py
Log:
Simplifies and improves the "abbreviation" of x-axis values.



Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py	2008-01-13 18:56:33 UTC (rev 1555)
+++ mgmt/cumin/python/cumin/charts.py	2008-01-13 18:57:33 UTC (rev 1556)
@@ -12,14 +12,10 @@
         self.surface = ImageSurface(FORMAT_ARGB32, width + 60, height + 20)
         self.surface.set_device_offset(0.5, 8.5)
         self.x_max = 1
+        self.x_min = 0
         self.y_max = 1
+        self.y_min = 0
 
-    def set_x_max(self, value):
-        self.x_max = value
-
-    def set_y_max(self, value):
-        self.y_max = value
-
     def plot_values(self, samples, color=(0, 0, 0)):
         cr = Context(self.surface)
         cr.set_line_width(2)
@@ -82,12 +78,14 @@
             cr.line_to(self.width + 2, y)
 
             if i % step == 0:
-                value = int(self.y_max - (self.y_max * y / float(self.height)))
+                value = self.y_max - (self.y_max * y / float(self.height))
 
-                if value > 10000:
-                    svalue = "%ik" % (value / 1000)
+                if value < 10:
+                    svalue = "%0.0f" % value
+                elif value > 10000:
+                    svalue = "%ik" % int(round(value / 1000, -1))
                 else:
-                    svalue = str(value)
+                    svalue = str(int(round(value, -1)))
 
                 cr.show_text(svalue)
 

Modified: mgmt/cumin/python/cumin/stat.py
===================================================================
--- mgmt/cumin/python/cumin/stat.py	2008-01-13 18:56:33 UTC (rev 1555)
+++ mgmt/cumin/python/cumin/stat.py	2008-01-13 18:57:33 UTC (rev 1556)
@@ -178,31 +178,26 @@
             if vals:
                 max_value = max(max(vals), max_value)
 
-        max_value = int(max_value * 1.1)
+        max_value = int(max_value * 1.1) + 1
 
-        if max_value < 10:
-            round = 6
-        elif max_value < 100:
-            round = 60
-        elif max_value < 10000:
-            round = 600
-        else:
-            round = 6000
+        chart.x_max = duration
+        chart.y_max = max_value
 
-        max_value = max_value + (round - max_value % round)
-
-        chart.set_x_max(duration)
-        chart.set_y_max(max_value)
-
         x_interval = 40
-        step = 2
+        x_step = 2
 
-        if duration == 600:
+        if chart.x_max == 600:
             x_interval = 48
 
-        chart.plot_x_axis(x_interval, step)
-        chart.plot_y_axis(20, 2)
+        y_interval = 15
+        y_step = 2
 
+        if chart.y_max < 4:
+            y_step = 4
+
+        chart.plot_x_axis(x_interval, x_step)
+        chart.plot_y_axis(y_interval, y_step)
+
         colors = ((1,0,0), (0,0,1), (0,1,0))
 
         for stat, color in zip(stats, colors):




More information about the rhmessaging-commits mailing list