diff options
| author | Antony Lesuisse <al@openerp.com> | 2014-05-01 19:25:08 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2014-05-01 19:25:08 +0200 |
| commit | 5e21a4235d1c1b5b8d10a1f4fef147f84812ce5f (patch) | |
| tree | 19c3ec192b18549dd37b20da8a5aca8bf859bab9 /addons/web_graph/static/src/js/graph_widget.js | |
| parent | 2998bec0e0684fae3e5755e4c86354d8576dba53 (diff) | |
| parent | abbe08f76a87be47c78abafa7b0af0064df3a6a4 (diff) | |
[MERGE] saas-4 up to dle@openerp.com-20140501121915-q88k37nd25ietw8c
bzr revid: al@openerp.com-20140501172508-tjennzht30ktw3nz
Diffstat (limited to 'addons/web_graph/static/src/js/graph_widget.js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index ce73a0b51c6..9946e149d96 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -51,7 +51,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.search_view = parent.searchview; openerp.session.rpc('/web_graph/check_xlwt').then(function (result) { - self.$('.graph_options_selection label').toggle(result); + self.$('.graph_options_selection label').last().toggle(result); }); return this.model.call('fields_get', []).then(function (f) { @@ -296,11 +296,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ if (header.expanded) { this.fold(header); return; - } + } if (header.path.length < header.root.groupby.length) { this.expand(id); return; - } + } if (!this.important_fields.length) { return; } @@ -499,10 +499,12 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Main display method // ---------------------------------------------------------------------- display_data: function () { + var scroll = $(window).scrollTop(); this.$('.graph_main_content svg').remove(); this.$('.graph_main_content div').remove(); this.table.empty(); this.table.toggleClass('heatmap', this.heatmap_mode !== 'none'); + this.$('.graph_options_selection label').last().toggleClass('disabled', this.pivot.no_data); this.width = this.$el.width(); this.height = Math.min(Math.max(document.documentElement.clientHeight - 116 - 60, 250), Math.round(0.8*this.$el.width())); @@ -512,6 +514,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else { if (this.mode === 'pivot') { this.draw_table(); + $(window).scrollTop(scroll); } else { this.$('.graph_main_content').append($('<div><svg>')); this.svg = this.$('.graph_main_content svg')[0]; @@ -626,7 +629,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ if ((dim_x === 0) && (dim_y === 0)) { data = [{key: _t('Total'), values:[{ x: _t('Total'), - y: this.pivot.get_total(), + y: this.pivot.get_total()[0], }]}]; // Only column groupbys } else if ((dim_x === 0) && (dim_y >= 1)){ @@ -639,7 +642,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Just 1 row groupby } else if ((dim_x === 1) && (dim_y === 0)) { data = _.map(this.pivot.main_row().children, function (pt) { - var value = self.pivot.get_total(pt), + var value = self.pivot.get_total(pt)[0], title = (pt.title !== undefined) ? pt.title : _t('Undefined'); return {x: title, y: value}; }); @@ -676,8 +679,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ nv.addGraph(function () { var chart = nv.models.multiBarChart() - .width(self.width) - .height(self.height) .reduceXTicks(false) .stacked(self.bar_ui === 'stack') .showControls(show_controls); @@ -705,9 +706,12 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ dim_x = this.pivot.rows.groupby.length, dim_y = this.pivot.cols.groupby.length; + var rows = this.pivot.get_rows_with_depth(dim_x), + labels = _.pluck(rows, 'title'); + var data = _.map(this.pivot.get_cols_leaves(), function (col) { - var values = _.map(self.pivot.get_rows_with_depth(dim_x), function (row) { - return {x: row.title, y: self.pivot.get_values(row.id,col.id)[0] || 0}; + var values = _.map(rows, function (row, index) { + return {x: index, y: self.pivot.get_values(row.id,col.id)[0] || 0}; }); var title = _.map(col.path, function (p) { return p || _t('Undefined'); @@ -720,10 +724,9 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ nv.addGraph(function () { var chart = nv.models.lineChart() - .x(function (d,u) { return u; }) - .width(self.width) - .height(self.height) - .margin({top: 30, right: 20, bottom: 20, left: 60}); + .x(function (d,u) { return u; }); + + chart.xAxis.tickFormat(function (d,u) {return labels[d];}); d3.select(self.svg) .attr('width', self.width) @@ -745,14 +748,14 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ if (dim_x === 0) { title = self.measure_label; } - return {x: title, y: self.pivot.get_total(row)}; + return {x: title, y: self.pivot.get_total(row)[0]}; }); nv.addGraph(function () { var chart = nv.models.pieChart() - .color(d3.scale.category10().range()) .width(self.width) - .height(self.height); + .height(self.height) + .color(d3.scale.category10().range()); d3.select(self.svg) .datum(data) |
