From 0241b762b21ea66efc91cc78133463bc9e683ef2 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 22 Apr 2014 17:04:41 +0200 Subject: [PATCH] [FIX] fix line chart x-axis labels: it now correctly uses the name of the row, and not a number (addon web_graph) bzr revid: ged@openerp.com-20140422150441-3vll2jw69z319yza --- addons/web_graph/static/src/js/graph_widget.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 1941047c437..9091bf2b4da 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -688,9 +688,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'); @@ -705,6 +708,8 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ var chart = nv.models.lineChart() .x(function (d,u) { return u; }); + chart.xAxis.tickFormat(function (d,u) {return labels[d];}); + d3.select(self.svg) .attr('width', self.width) .attr('height', self.height)