diff options
| author | Gery Debongnie <ged@openerp.com> | 2013-12-11 11:22:46 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2013-12-11 11:22:46 +0100 |
| commit | 2cf5049cf170f2560ce398f401adae9d7c2f1614 (patch) | |
| tree | a5a3487b46216da6dcb99ab649d84d1968d131b8 /addons/web_graph/static/src | |
| parent | 4416acaa5391860a010a03a05d82fa7c5f6b9b57 (diff) | |
[IMP] improves the way line chart format the different titles in the legend (addon web_graph)
bzr revid: ged@openerp.com-20131211102246-88y7r63d6wgvz4u5
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/js/charts.js | 22 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/pivot.js | 14 |
2 files changed, 25 insertions, 11 deletions
diff --git a/addons/web_graph/static/src/js/charts.js b/addons/web_graph/static/src/js/charts.js index 7478668865c..b4a958ded5b 100644 --- a/addons/web_graph/static/src/js/charts.js +++ b/addons/web_graph/static/src/js/charts.js @@ -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 () { diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js index 78f95548106..cc43329e0b1 100644 --- a/addons/web_graph/static/src/js/pivot.js +++ b/addons/web_graph/static/src/js/pivot.js @@ -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) { |
