diff options
| author | Gery Debongnie <ged@openerp.com> | 2013-12-31 10:49:29 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2013-12-31 10:49:29 +0100 |
| commit | d63db7b67f817178a3698904cacdd655676ed673 (patch) | |
| tree | 00868b24577c23223b730ef19485f111539857a9 /addons/web_graph/static/src/js | |
| parent | b9f9857454aa4c7db23ee366945528775f798ec9 (diff) | |
[IMP] makes sure that the graph view properly honors default mode request as described in the xml (addon web_graph)
bzr revid: ged@openerp.com-20131231094929-giqkzmean1lralow
Diffstat (limited to 'addons/web_graph/static/src/js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 9fcb7f3ea8e..8c652239d2a 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -54,9 +54,28 @@ instance.web_graph.GraphView = instance.web.View.extend({ measure = null, stacked = false; - if (arch.attrs.type === 'bar' || !_.has(arch.attrs, 'type')) { + if (!_.has(arch.attrs, 'type')) { this.graph_widget.mode = 'bar_chart'; + } else { + switch (arch.attrs.type) { + case 'bar': + this.graph_widget.mode = 'bar_chart'; + break; + case 'pie': + this.graph_widget.mode = 'pie_chart'; + break; + case 'line': + this.graph_widget.mode = 'line_chart'; + break; + case 'pivot': + case 'heatmap': + case 'row_heatmap': + case 'col_heatmap': + this.graph_widget.mode = arch.attrs.type; + break; + } } + if (arch.attrs.stacked === 'True') { stacked = true; } @@ -190,7 +209,6 @@ instance.web_graph.Graph = instance.web.Widget.extend({ this.fields = []; this.pivot = new openerp.web_graph.PivotTable(model, []); this.mode = 'pivot'; - if (_.has(options, 'mode')) { this.mode = mode; } this.enabled = true; if (_.has(options, 'enabled')) { this.enabled = options.enabled; } this.visible_ui = true; @@ -200,6 +218,9 @@ instance.web_graph.Graph = instance.web.Widget.extend({ // hide ui/show, stacked/grouped config: function (options) { + // Possible modes: pivot, heatmap, row_heatmap, col_heatmap, + // bar_chart, pie_chart, line_chart + if (_.has(options, 'mode')) { this.mode = mode; } if (_.has(options, 'visible_ui')) { this.visible_ui = options.visible_ui; } @@ -509,17 +530,17 @@ instance.web_graph.Graph = instance.web.Widget.extend({ cell.append(instance.web.format_value(value, {type: measure_type})); if (self.mode === 'heatmap') { total = pivot.get_total(); - color = Math.floor(50 + 205*(total - value)/total); + color = Math.floor(90 + 165*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } if (self.mode === 'row_heatmap') { total = pivot.get_total(row); - color = Math.floor(50 + 205*(total - value)/total); + color = Math.floor(90 + 165*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } if (self.mode === 'col_heatmap') { total = pivot.get_total(col); - color = Math.floor(50 + 205*(total - value)/total); + color = Math.floor(90 + 165*(total - value)/total); cell.css('background-color', $.Color(255, color, color)); } return cell; |
