diff options
| author | Martin Trigaux <mat@openerp.com> | 2013-04-12 17:21:50 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2013-04-12 17:21:50 +0200 |
| commit | b18bc579197837ddcc97d9f7292d8cec3bc05d49 (patch) | |
| tree | 4575c872d76e90d575b00da3b47ad50e4c96dff2 /addons/gamification/static/src/js/gamification.js | |
| parent | 8f05129bcda7de790b33b561330dcd881f5c8da2 (diff) | |
[ADD] use sparklines
bzr revid: mat@openerp.com-20130412152150-8679huigt6cfmool
Diffstat (limited to 'addons/gamification/static/src/js/gamification.js')
| -rw-r--r-- | addons/gamification/static/src/js/gamification.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index a856d057172..aafdcbf8659 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -64,6 +64,7 @@ openerp.gamification = function(instance) { self.render_template_replace(self.$el.filter(".oe_gamification_goal"),'gamification.goal_list_to_do'); self.render_money_fields(self.goals_info.info[0].currency); self.render_progress_bars(); + self.render_piechars(); } }); }, @@ -72,7 +73,7 @@ openerp.gamification = function(instance) { self.dfm = new instance.web.form.DefaultFieldManager(self); // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$el.find(".oe_goal_field_monetary").each(function() { + self.$(".oe_goal_field_monetary").each(function() { money_field = new instance.web.form.FieldMonetary(self.dfm, { attrs: { modifiers: '{"readonly": true}' @@ -89,7 +90,7 @@ openerp.gamification = function(instance) { dfm = new instance.web.form.DefaultFieldManager(self); // Generate a FieldMonetary for each .oe_goal_field_monetary - self.$el.find(".oe_goal_progress").each(function() { + self.$(".oe_goal_progress").each(function() { progress_field = new instance.web.form.FieldProgressBar(dfm, { attrs: { modifiers: '{"readonly": true}' @@ -98,6 +99,14 @@ openerp.gamification = function(instance) { progress_field.set('value', $(this).attr('value')); progress_field.replace($(this)); }); + }, + render_piechars: function() { + var self = this; + self.$(".oe_goal_sparkline_piechart").each(function() { + var completeness = parseInt( $(this).attr('data-completeness'), 10); + var values = [completeness, 100-completeness]; + $(this).sparkline(values, {type: 'pie', offset: 180, sliceColors: ['#01922D','#ff0000']}); + }); } }); @@ -143,8 +152,8 @@ openerp.gamification = function(instance) { // }, label: self.record.type_suffix.raw_value, levelColors: [ - "#f9c802", "#ff0000", + "#f9c802", "#a9d70b" ], }); |
