diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 119d0b12e16..c1c2b52f4b8 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -363,8 +363,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ }); if (pivot.cols.main.children.length > 0) { - var row_total = pivot.get_value(row.id, pivot.cols.main.id), - cell = make_cell(row_total, pivot.cols.main) + var cell = make_cell(pivot.get_total(row), pivot.cols.main) .css('font-weight', 'bold'); html_row.append(cell); } @@ -384,16 +383,17 @@ instance.web_graph.GraphView = instance.web.View.extend({ } cell.append(value); if (self.mode === 'heatmap') { - color = Math.floor(50 + 205*(pivot.total - value)/pivot.total); + total = pivot.get_total(); + color = Math.floor(50 + 205*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } if (self.mode === 'row_heatmap') { - total = pivot.get_value(row.id, pivot.cols.main.id); + total = pivot.get_total(row); color = Math.floor(50 + 205*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } if (self.mode === 'col_heatmap') { - total = pivot.get_value(col.id, pivot.rows.main.id); + total = pivot.get_total(col); color = Math.floor(50 + 205*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js index a87dfada7d5..68c5ca43a3e 100644 --- a/addons/web_graph/static/src/js/pivot.js +++ b/addons/web_graph/static/src/js/pivot.js @@ -12,7 +12,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ this.model = options.model; this.domain = options.domain; this.measure = options.measure; - this.total = 0; this.id_seed = 0; this.no_data = true; }, @@ -168,7 +167,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ self.cells = result.cells; self.rows.main = self.rows.headers[0]; self.cols.main = self.cols.headers[0]; - self.total = self.rows.main.total; self.rows.main.title = ''; self.cols.main.title = ''; _.each(self.rows.headers, function (row) { @@ -186,6 +184,15 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ }); }, + get_total: function (header) { + if (header) { + var main = (header.root === this.rows) ? this.cols.main : this.rows.main; + return this.get_value(header.id, main.id); + } else { + return this.rows.main.total; + } + }, + update_values: function () { var self = this; return this.query_all_values().then(function (result) { @@ -226,8 +233,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ return updated_headers; } - // now some more tweaks - self.total = self.rows.main.total; _.each(self.rows.headers, function (row) { row.root = self.rows; }); @@ -341,7 +346,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ function make_tree_headers (data_pt, parent, max_depth) { var node = { id: self.generate_id(), - total: data_pt.attributes.aggregates[self.measure], path: parent.path.concat(data_pt.attributes.value[1]), title: data_pt.attributes.value[1], domain: data_pt.model._domain,