diff options
| author | Gery Debongnie <ged@openerp.com> | 2013-12-11 11:30:32 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2013-12-11 11:30:32 +0100 |
| commit | 4ab861699179e35e513c2cd6ac2c0e77c8e513bb (patch) | |
| tree | 398ae56238eaa065326fb7b72c4f5b177aa39e8e /addons/web_graph/static | |
| parent | 2cf5049cf170f2560ce398f401adae9d7c2f1614 (diff) | |
[IMP] makes pie charts smarter when dealing with multiple levels of rows, in graph view (addon web_graph)
bzr revid: ged@openerp.com-20131211103032-6vl1nys24zufuk5w
Diffstat (limited to 'addons/web_graph/static')
| -rw-r--r-- | addons/web_graph/static/src/js/charts.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/addons/web_graph/static/src/js/charts.js b/addons/web_graph/static/src/js/charts.js index b4a958ded5b..f0025510f9c 100644 --- a/addons/web_graph/static/src/js/charts.js +++ b/addons/web_graph/static/src/js/charts.js @@ -184,7 +184,7 @@ openerp.web_graph.line_chart = function (pivot, svg, measure_label) { return p || 'Undefined'; }).join('/'); if (dim_y === 0) { - title = measure_label + title = measure_label; } return {values: values, key: title}; }); @@ -206,13 +206,20 @@ openerp.web_graph.line_chart = function (pivot, svg, measure_label) { }); }; -openerp.web_graph.pie_chart = function (pivot, svg) { - var data = _.map(pivot.rows.main.children, function (pt) { - var value = pivot.get_value(pt.id, pivot.cols.main.id), - title = (pt.title !== undefined) ? pt.title : 'Undefined'; - return {x: title, y: value}; +openerp.web_graph.pie_chart = function (pivot, svg, measure_label) { + var dim_x = pivot.rows.groupby.length, + dim_y = pivot.cols.groupby.length; + + var data = _.map(pivot.get_rows_leaves(), function (row) { + var title = _.map(row.path, function (p) { + return p || 'Undefined'; + }).join('/'); + if (dim_x === 0) { + title = measure_label; + } + return {x: title, y: pivot.get_total(row)}; }); - + nv.addGraph(function () { var chart = nv.models.pieChart() .color(d3.scale.category10().range()) |
