Author: eallen
Date: 2010-08-04 11:20:33 -0400 (Wed, 04 Aug 2010)
New Revision: 4186
Modified:
mgmt/newdata/cumin/python/cumin/stat.py
Log:
Fix bug in flash pie chart. The colors of the slices would change after the chart was
displayed.
Modified: mgmt/newdata/cumin/python/cumin/stat.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/stat.py 2010-08-02 21:41:33 UTC (rev 4185)
+++ mgmt/newdata/cumin/python/cumin/stat.py 2010-08-04 15:20:33 UTC (rev 4186)
@@ -586,7 +586,15 @@
def create(self, session, adapter, stats):
names = self.page.names.get(session)
values = self.page.values.get(session)
+ nvs = dict()
+ for name, value in zip(names, values):
+ nvs[name] = value
+ # move Unclaimed to end of list
+ sorted_names = sorted(names)
+ sorted_names.remove("Unclaimed")
+ sorted_names.append("Unclaimed")
+
chart = Chart()
chart.title.text = ""
chart.bg_colour = "#FFFFFF"
@@ -610,9 +618,9 @@
element.tip = "#percent#"
element.colours = []
- for i in range(len(names)):
+ for i in range(len(sorted_names)):
j = i % len(self.colors)
- if names[i] == "Unclaimed":
+ if sorted_names[i] == "Unclaimed":
color = "#EEEEEE"
else:
color = self.colors[j]
@@ -623,7 +631,7 @@
id = self.page.chart_id.get(session)
element.on_click_text = "#percent#|#val#|#label#|%s" % id
- element.values = [{"label": name, "value": float(value)} for
name, value in zip(names, values)]
+ element.values = [{"label": x, "value": float(nvs[x])} for x
in sorted_names]
chart.elements.append(element)
return chart.create()
Show replies by date