summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2013-11-24 15:52:40 +0100
committerGery Debongnie <ged@openerp.com>2013-11-24 15:52:40 +0100
commit5173a56db659f91eb71255bcecb0cfe072f54cdb (patch)
tree7720fe8b43317f1ee91aec96307f68fbbb1235ca /addons/web_graph/static/src/js/graph.js
parentaa5958eaf5bab2bc193eea7e1a1e76644967b9ce (diff)
[IMP] add heat map functionality to pivot table (addon web_graph)
bzr revid: ged@openerp.com-20131124145240-dn5vq5ecb598gf4e
Diffstat (limited to 'addons/web_graph/static/src/js/graph.js')
-rw-r--r--addons/web_graph/static/src/js/graph.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js
index c0ccb80285a..037a07c60ec 100644
--- a/addons/web_graph/static/src/js/graph.js
+++ b/addons/web_graph/static/src/js/graph.js
@@ -77,6 +77,11 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.pivot_table.fold_cols();
this.draw_table();
},
+
+ 'click label.graph_heat_map' : function (event) {
+ this.heat_map_mode = !this.heat_map_mode;
+ this.draw_table();
+ },
},
view_loading: function (fields_view_get) {
@@ -90,6 +95,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
row_groupby = [];
this.pivot_table = null;
+ this.heat_map_mode = false;
// get the default groupbys and measure defined in the field view
_.each(fields_view_get.arch.children, function (field) {
@@ -300,7 +306,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
},
draw_row: function (row) {
- var pivot = this.pivot_table,
+ var self = this,
+ pivot = this.pivot_table,
html_row = $('<tr></tr>'),
row_header = this.make_border_cell(1,1)
.append(this.make_header_title(row).attr('data-row-id', row.id))
@@ -314,7 +321,17 @@ instance.web_graph.GraphView = instance.web.View.extend({
_.each(pivot.cols.headers, function (col) {
if (col.children.length === 0) {
- var cell = $('<td></td>').append(pivot.get_value(row.id, col.id));
+ var value = pivot.get_value(row.id, col.id),
+ cell = $('<td></td>');
+
+ cell.append((value === undefined) ? '' : value);
+ if ((self.heat_map_mode) && (value !== undefined)) {
+ // heat map
+ console.log("heat map", self.heat_map_mode, pivot.total);
+ var ratio = Math.floor(70 + 185*(pivot.total - value)/pivot.total);
+ console.log("ratio",ratio);
+ cell.css("background-color", "rgb(255," + ratio + "," + ratio + ")");
+ }
html_row.append(cell);
}
});