diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-02-17 11:17:31 +0100 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-02-17 11:17:31 +0100 |
| commit | 1e9380b8faf05aa5ccb7fdfaf7309c362b1963bb (patch) | |
| tree | e49a42e01b00a5e95522a93c720762d487b17fd8 /addons/web_graph/static/src | |
| parent | affc2d4d04539d452ee207eef2c01238df72d1ef (diff) | |
| parent | 9f65e1565e785fd1c11fef65e7b49e78fba290ed (diff) | |
[merge]
bzr revid: nicolas.vanhoren@openerp.com-20120217101731-3g9hrhs65qb32pkv
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 966f3c1b006..b7b6063189f 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -183,7 +183,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ var self = this; var group_list, view_chart = (self.chart == 'line')?'line':(self.chart == 'area')?'area':''; - if (!this.group_field) { + if (!this.group_field || !results.length) { if (self.chart == 'bar'){ view_chart = (this.orientation === 'horizontal') ? 'barH' : 'bar'; } @@ -216,9 +216,12 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ .pluck(this.group_field) .uniq() .map(function (value, index) { + var groupval = ''; + if(value) { + groupval = value.toLowerCase().replace(/[\s\/]+/g,'_'); + } return { - group: self.ordinate + '_' + - value.toLowerCase().replace(/[\s\/]+/g,'_'), + group: _.str.sprintf('%s_%s', self.ordinate, groupval), text: value, color: COLOR_PALETTE[index % COLOR_PALETTE.length] }; @@ -231,9 +234,11 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ // second argument is coerced to a str, no good for boolean r[self.abscissa] = records[0][self.abscissa]; _(records).each(function (record) { - var key = _.str.sprintf('%s_%s', - self.ordinate, - record[self.group_field].toLowerCase().replace(/[\s\/]+/g,'_')); + var value = record[self.group_field]; + if(value) { + value = value.toLowerCase().replace(/[\s\/]+/g,'_'); + } + var key = _.str.sprintf('%s_%s', self.ordinate, value); r[key] = record[self.ordinate]; }); return r; @@ -349,7 +354,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ self.renderer = null; var chart = new dhtmlXChart({ view:"pie3D", - container:self.element_id+"-piechart", + container:self.widget_parent.element_id+"-piechart", value:"#"+self.ordinate+"#", pieInnerText:function(obj) { var sum = chart.sum("#"+self.ordinate+"#"); |
