[IMP] improves the way line chart format the different titles in the legend (addon web_graph)

bzr revid: ged@openerp.com-20131211102246-88y7r63d6wgvz4u5
This commit is contained in:
Gery Debongnie 2013-12-11 11:22:46 +01:00
parent 4416acaa53
commit 2cf5049cf1
2 changed files with 25 additions and 11 deletions

View File

@ -173,20 +173,20 @@ openerp.web_graph.bar_chart = function (pivot, svg, measure_label) {
openerp.web_graph.line_chart = function (pivot, svg, measure_label) {
var data = [],
dim_x = pivot.rows.groupby.length,
var dim_x = pivot.rows.groupby.length,
dim_y = pivot.cols.groupby.length;
if (dim_y === 0) {
pivot.cols.main.title = measure_label;
}
_.each(pivot.cols.headers, function (col) {
if (!col.is_expanded) {
var values = _.map(pivot.get_rows_depth(dim_x), function (row) {
return {x: row.title, y: pivot.get_value(row.id,col.id, 0)};
});
data.push({values: values, key: col.title || 'Undefined'});
var data = _.map(pivot.get_cols_leaves(), function (col) {
var values = _.map(pivot.get_rows_depth(dim_x), function (row) {
return {x: row.title, y: pivot.get_value(row.id,col.id, 0)};
});
var title = _.map(col.path, function (p) {
return p || 'Undefined';
}).join('/');
if (dim_y === 0) {
title = measure_label
}
return {values: values, key: title};
});
nv.addGraph(function () {

View File

@ -114,6 +114,20 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
});
},
// return all non expanded rows
get_rows_leaves: function () {
return _.filter(this.rows.headers, function (hdr) {
return !hdr.is_expanded;
});
},
// return all non expanded cols
get_cols_leaves: function () {
return _.filter(this.cols.headers, function (hdr) {
return !hdr.is_expanded;
});
},
fold: function (header) {
var list = [];
function tree_traversal(tree) {