[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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user