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

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Oct 25 15:36:05 EDT 2007


Author: justi9
Date: 2007-10-25 15:36:05 -0400 (Thu, 25 Oct 2007)
New Revision: 1162

Modified:
   mgmt/cumin/python/cumin/charts.py
   mgmt/cumin/python/cumin/queue.strings
Log:
Chart improvements.



Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py	2007-10-25 17:38:48 UTC (rev 1161)
+++ mgmt/cumin/python/cumin/charts.py	2007-10-25 19:36:05 UTC (rev 1162)
@@ -9,23 +9,34 @@
     def __init__(self, width, height):
         self.width = width
         self.height = height
-        self.surface = ImageSurface(FORMAT_ARGB32, width, height)
-    
+        self.surface = ImageSurface(FORMAT_ARGB32, width + 40, height + 20)
+        self.max_value = 1
+
+    def set_max_value(self, value):
+        self.max_value = value
+
     def plot_values(self, values, interval=5, color=(0, 0, 0)):
-        max_value = max(100, max(values) * 1.2)
-
         cr = Context(self.surface)
         cr.set_line_width(2)
         cr.set_source_rgb(*color)
 
         for x, value in zip(range(self.width, 0, -interval), reversed(values)):
-            y = self.height - (value / float(max_value)) * self.height
+            y = self.height - (value / float(self.max_value)) * self.height
             cr.line_to(x, y)
 
         cr.stroke()
 
-    def plot_intervals(self, interval=40):
+    def plot_frame(self, color=(0.8, 0.8, 0.8)):
         cr = Context(self.surface)
+        cr.set_line_width(1)
+        cr.set_source_rgb(*color)
+        
+        cr.rectangle(0.5, 0.5, self.width, self.height)
+
+        cr.stroke()
+
+    def plot_x_intervals(self, interval=40):
+        cr = Context(self.surface)
         cr.set_line_width(0.2)
         cr.set_source_rgb(0.8, 0.8, 0.8)
 
@@ -35,6 +46,17 @@
 
         cr.stroke()
 
+    def plot_y_axis(self):
+        cr = Context(self.surface)
+
+        x = self.width + 2
+
+        cr.move_to(x, 9)
+        cr.show_text(str(self.max_value))
+
+        cr.move_to(x, self.height)
+        cr.show_text("0")
+
     def write(self, name):
         self.surface.write_to_png(name)
 
@@ -59,10 +81,21 @@
 
     def do_render(self, session, queue):
         chart = LineChart(600, 120)
-        chart.plot_intervals()
 
         measures = [queue.get_measurement(x) \
                     for x in self.measurements.get(session)]
+
+        max_value = 0
+        for m in measures:
+            max_value = max(max(m.values), max_value)
+        max_value = max_value * 1.1
+        max_value = max_value + (100 - max_value % 100)
+        chart.set_max_value(int(max_value))
+
+        chart.plot_x_intervals()
+        chart.plot_y_axis()
+        chart.plot_frame()
+
         colors = ((1,0,0), (0,0,1), (0,1,0))
 
         for m, c in zip(measures, colors):

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-10-25 17:38:48 UTC (rev 1161)
+++ mgmt/cumin/python/cumin/queue.strings	2007-10-25 19:36:05 UTC (rev 1162)
@@ -206,10 +206,12 @@
 </table>
 
 [StatisticsHistory.css]
+/*
 .chart img {
   background-color: #f9f9f9;
   border: 1px dotted #ddd;
 }
+*/
 
 [StatisticsHistory.html]
 <h2>Queue Depth</h2>




More information about the rhmessaging-commits mailing list