[IMP] improves the chart code to display correct bar chart when no row groupby are selected and a positive number of col groupbys are selected (graph view, addon web_graph)
bzr revid: ged@openerp.com-20131210100723-0arehl16k54wln0z
This commit is contained in:
parent
f24a1b487a
commit
fe5543a043
|
@ -7,16 +7,43 @@ openerp.web_graph.draw_chart = function (mode, pivot, svg) {
|
|||
openerp.web_graph.bar_chart = function (pivot, svg) {
|
||||
var dim_x = pivot.rows.groupby.length,
|
||||
dim_y = pivot.cols.groupby.length,
|
||||
data;
|
||||
data = [];
|
||||
|
||||
if ((dim_x === 0) && (dim_y === 0)) {
|
||||
data = [{key: 'Expected Revenue', values:[{
|
||||
title: 'Total',
|
||||
value: pivot.get_value(pivot.rows.main.id, pivot.cols.main.id),
|
||||
}]}];
|
||||
// debugger;
|
||||
} else if ((dim_x === 0) && (dim_y === 1)){
|
||||
|
||||
} else if ((dim_x === 0) && (dim_y >= 1)){
|
||||
_.each(pivot.cols.headers, function (header) {
|
||||
if (header.path.length === 1) {
|
||||
data.push({
|
||||
key: header.title,
|
||||
values: [{x:header.root.main.title, y: pivot.get_total(header)}]
|
||||
});
|
||||
}
|
||||
});
|
||||
nv.addGraph(function() {
|
||||
var chart = nv.models.multiBarChart()
|
||||
.stacked(true)
|
||||
.tooltips(false)
|
||||
.showControls(false)
|
||||
.width(400)
|
||||
.height(500);
|
||||
|
||||
d3.select(svg)
|
||||
.datum(data)
|
||||
.attr('width', 400)
|
||||
.attr('height', 500)
|
||||
.transition()
|
||||
.duration(500)
|
||||
.call(chart);
|
||||
|
||||
nv.utils.windowResize(chart.update);
|
||||
|
||||
return chart;
|
||||
});
|
||||
return;
|
||||
} else
|
||||
{
|
||||
data = _.map(pivot.rows.main.children, function (pt) {
|
||||
|
|
Loading…
Reference in New Issue