summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2013-11-27 15:45:05 +0100
committerGery Debongnie <ged@openerp.com>2013-11-27 15:45:05 +0100
commit574253bb63dc3d9a630033336c2d2dad9adf9e12 (patch)
tree87284e327dc9d86b7cf067837105d245bd5d677b /addons/web_graph/static/src/js
parent6e88cce3fb48c9ee780bb043f7ba548eb6e98d77 (diff)
[REF] improves the draw_row method which will allow to support row_heat_map and col_heatmap in table view (addon web_graph)
bzr revid: ged@openerp.com-20131127144505-fq1bb3xv97a2ek38
Diffstat (limited to 'addons/web_graph/static/src/js')
-rw-r--r--addons/web_graph/static/src/js/graph.js44
1 files changed, 21 insertions, 23 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js
index 78fb16582a9..1b18e9cd181 100644
--- a/addons/web_graph/static/src/js/graph.js
+++ b/addons/web_graph/static/src/js/graph.js
@@ -333,38 +333,36 @@ instance.web_graph.GraphView = instance.web.View.extend({
_.each(pivot.cols.headers, function (col) {
if (col.children.length === 0) {
var value = pivot.get_value(row.id, col.id),
- cell = $('<td></td>');
-
- cell.append((value === undefined) ? '' : value);
- if ((self.mode == 'heatmap') && (value !== undefined)) {
- var color = Math.floor(50 + 205*(pivot.total - value)/pivot.total);
- cell.css('background-color', 'rgb(255,' + color + ',' + color + ')');
- }
- if (row.is_expanded && (row.path.length <= 2)) {
- var color = row.path.length * 5 + 240;
- cell.css('background-color', 'rgb(' + [color, color, color].join() + ')');
- }
+ cell = make_cell(value);
html_row.append(cell);
}
});
- var total = pivot.get_value(row.id, pivot.cols.main.id);
- var cell = $('<td></td>')
- .append(total)
- .css('font-weight', 'bold');
- if (row.is_expanded && (row.path.length <= 2)) {
- var color = row.path.length * 5 + 240;
- cell.css('background-color', 'rgb(' + [color, color, color].join() + ')');
- } else if (self.heat_map_mode) {
- var color = Math.floor(50 + 205*(pivot.total - total)/pivot.total);
- cell.css('background-color', 'rgb(255,' + color + ',' + color + ')');
- }
if (pivot.cols.main.children.length > 0) {
+ var row_total = pivot.get_value(row.id, pivot.cols.main.id),
+ cell = make_cell(row_total).css('font-weight', 'bold');
html_row.append(cell);
}
this.table.append(html_row);
- }
+
+ function make_cell (value) {
+ var color,
+ cell = $('<td></td>');
+ if (value !== undefined) {
+ cell.append(value);
+ }
+ if ((self.mode === 'pivot') && (row.is_expanded) && (row.path.length <=2)) {
+ color = row.path.length * 5 + 240;
+ cell.css('background-color', $.Color(color, color, color));
+ }
+ if (self.mode === 'heatmap') {
+ color = Math.floor(50 + 205*(pivot.total - value)/pivot.total);
+ cell.css('background-color', $.Color(255, color, color));
+ }
+ return cell;
+ }
+ },
});
};