Author: eallen
Date: 2009-08-12 14:44:22 -0400 (Wed, 12 Aug 2009)
New Revision: 3570
Modified:
mgmt/trunk/cumin/python/cumin/stat.py
mgmt/trunk/cumin/python/cumin/stat.strings
Log:
Removed hard-coded values from flash pie charts.
Allow flash charts to get the names and values of the pie slices from parameters. This
avoids calling the qmf methods a second time.
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-08-12 18:38:49 UTC (rev 3569)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-08-12 18:44:22 UTC (rev 3570)
@@ -172,10 +172,10 @@
def render_stat_name(self, session, stat, object):
return stat.name
- def render_width(self, session, object):
+ def render_width(self, session, *args):
return 360
- def render_height(self, session, object):
+ def render_height(self, session, *args):
return 100
class StatStackedChart(StatValueChart):
@@ -212,16 +212,12 @@
params = self.get_href_params(session, object)
return "flashpage.html?" + ";".join(params)
- def render_width(self, session, object):
+ def render_width(self, session, *args):
return 360
- def render_height(self, session, object):
+ def render_height(self, session, *args):
return 120
-class PieFlashChart(StatFlashChart):
- def render_height(self, session, object):
- return 200
-
class ImageCache(object):
def __init__(self):
self.__files = dict() # {name: {"time": time_created, "file":
file object, "cookie": (cookie values)}}
@@ -506,8 +502,10 @@
recent = None
if len(stats):
- stat = stats[0]
+ stat = stats[0]
recent = stat.recent(object)
+ else:
+ return
if self.samples.get(session):
return self.render_samples(session, recent)
@@ -654,10 +652,10 @@
id = self.parent.id.get(session)
return (cls.get(id),)
- def render_width(self, session, object):
+ def render_width(self, session, *args):
return self.parent.container_width.get(session)
- def render_height(self, session, object):
+ def render_height(self, session, *args):
return self.parent.container_height.get(session)
def render_img_href(self, session, object):
@@ -715,15 +713,20 @@
return x_axis
class FlashPieChart(Widget):
+ colors = ['#FF0000', '#0000FF', '#00FF00', '#00FFFF',
'#FF00FF', '#000000', '#666600']
def __init__(self, app, name, page):
super(FlashPieChart, self).__init__(app, name)
self.page = page
- colors = ['#FF0000', '#0000FF', '#00FF00', '#FF00FF',
'#00FFFF', '#000000', '#666600']
def create(self, session, object):
- #stat = self.page.stats.get(session)[0]
- #action = self.app.model.negotiator.GetStats
- #group_stats = action.do_invoke(negotiator, 'developer')
+ names = self.page.names.get(session)
+ values = self.page.values.get(session)
+
+ #cls = self.page.class_.get(session)
+ #action = self.page.action.get(session)
+ #method = getattr(cls, action)
+ #values1 = method.do_invoke(object)
+
chart = Chart()
chart.title.text = ""
chart.bg_colour = "#FFFFFF"
@@ -744,21 +747,24 @@
animation.type = "bounce"
animation.distance = 8
element.animate.append(animation)
+ element.tip = "#percent#"
- element.tip = "#percent# (Click to modify)"
- element.colours = self.colors
+ element.colours = []
+ for i in range(len(names)):
+ j = i % len(self.colors)
+ if names[i] == "Unclaimed":
+ color = "#EEEEEE"
+ else:
+ color = self.colors[j]
+ element.colours.append(color)
+ element.colours.append("#EEEEEE")
+
element.on_click = "ofc_change_priority"
id = self.page.chart_id.get(session)
- element.on_click_text = "#val#|#label#|%s" % id
- element.values = [
- {"value": 2, "label": "fah"},
- {"value": 4, "label": "Development"},
- {"value": 7, "label": "Accounting"},
- {"value": 70, "label": "Rendering"},
- {"value": 6, "label": "Reporting"},
- {"value": 9, "label": "Management"}
- ]
+ element.on_click_text = "#percent#|#val#|#label#|%s" % id
+ element.values = [{"label": name, "value": float(value)} for
name, value in zip(names, values)]
+
chart.elements.append(element)
return chart.create()
@@ -1166,6 +1172,21 @@
self.chart_id = Parameter(app, "chart_id")
self.add_parameter(self.chart_id)
+ self.action = Parameter(app, "action")
+ self.add_parameter(self.action)
+
+ name = Parameter(app, "n")
+ self.add_parameter(name)
+
+ self.names = ListParameter(app, "name", name)
+ self.add_parameter(self.names)
+
+ val = Parameter(app, "v")
+ self.add_parameter(val)
+
+ self.values = ListParameter(app, "value", val)
+ self.add_parameter(self.values)
+
self.control_min = Parameter(app, "low")
ten_min_of_day = 10.0 / (24.0 * 60.0)
one_hour = 1 / 24.0
Modified: mgmt/trunk/cumin/python/cumin/stat.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.strings 2009-08-12 18:38:49 UTC (rev 3569)
+++ mgmt/trunk/cumin/python/cumin/stat.strings 2009-08-12 18:44:22 UTC (rev 3570)
@@ -298,19 +298,17 @@
</script>
[PieFlashChart.html]
-<div>
<div class="StatValueChart" id="{id}">
<h2>{title}</h2>
<div id="{id}_chart">
</div>
</div>
-</div>
<script type="text/javascript">
//<![CDATA[
var flashversion = swfobject.getFlashPlayerVersion();
if (flashversion.major >= 9) {
swfobject.embedSWF("resource?name=open-flash-chart.swf",
"{id}_chart", "{width}", "{height}", "9.0.0",
"",
- {"data-file":"{href}"});
+ {"data-file":"{href}"}, {wmode: 'opaque'});
}
//]]>
</script>