[rhmessaging-commits] rhmessaging commits: r3428 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Jun 8 10:35:02 EDT 2009


Author: eallen
Date: 2009-06-08 10:35:02 -0400 (Mon, 08 Jun 2009)
New Revision: 3428

Modified:
   mgmt/trunk/cumin/python/cumin/charts.py
   mgmt/trunk/cumin/python/cumin/stat.py
Log:
Better association of chart points and colors.
Round chart points before sending to browser to cut down on traffic.

Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py	2009-06-08 13:57:10 UTC (rev 3427)
+++ mgmt/trunk/cumin/python/cumin/charts.py	2009-06-08 14:35:02 UTC (rev 3428)
@@ -170,7 +170,7 @@
             cr.line_to(x, y)
             if x < 0:
                 break
-            points.append([int(x), int(y), value])
+            points.append([int(x), int(y), "%.2f" % value])
 
         cr.stroke()
         return points
@@ -217,7 +217,7 @@
     def plot_legend(self, titles, colors):
         cr = Context(self.surface)
         cr.set_line_width(1.5)
-        title_xy = list()
+        title_xy = dict()
 
         for i, item in enumerate(zip(titles, colors)):
             title, color = item
@@ -239,7 +239,7 @@
             cr.stroke()
 
             width, height = cr.text_extents(title)[2:4]
-            title_xy.append([width, y])
+            title_xy[color] = (width, y)
         return title_xy
 
     def plot_frame(self, color=(0.8, 0.8, 0.8)):

Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py	2009-06-08 13:57:10 UTC (rev 3427)
+++ mgmt/trunk/cumin/python/cumin/stat.py	2009-06-08 14:35:02 UTC (rev 3428)
@@ -418,16 +418,16 @@
             max_samples = int(width * 1.5)
             return max(int(duration / max_samples), 1)
 
-    def render_samples(self, session, recent, colors):
+    def render_samples(self, session, recent):
         c = {(1,0,0): "red", (0,0,1): "blue", (0,1,0): "green"}
         cached_samples, title_xy = self.get_cached_samples(session, recent)
         if cached_samples:
             rets = dict()
-            for stat, color, xy in zip(cached_samples, colors, title_xy):
+            for stat in cached_samples:
                 ret = dict()
-                ret["color"] = c[color]
-                ret["points"] = cached_samples[stat]
-                ret["xy"] = xy
+                ret["color"] = c[cached_samples[stat][1]]
+                ret["points"] = cached_samples[stat][0]
+                ret["xy"] = title_xy[cached_samples[stat][1]]
                 rets[stat.name] = ret
             return str(rets)
 
@@ -443,7 +443,7 @@
             recent = stat.recent(object)
 
         if self.samples.get(session):
-            return self.render_samples(session, recent, colors)
+            return self.render_samples(session, recent)
 
         if recent:
             cached_png = self.get_cached(session, recent)
@@ -517,7 +517,7 @@
 
         points = dict()
         for stat, color in zip(stats, colors):
-            points[stat] = chart.plot_values(samples[stat], color=color)
+            points[stat] = (chart.plot_values(samples[stat], color=color), color)
 
         for stat, color in zip(stats, colors):
             chart.plot_ticks(samples[stat], color=color)




More information about the rhmessaging-commits mailing list