[FIX] web: Graph: group by two fields on line chart

Before this commit, when we applied two or more groupbys in line
graph, the groups displayed on the X axis where shifted to the left,
and the first one wasn't displayed at all.

related task: #1848289
Closes: #25037
This commit is contained in:
Dipalee Bhalodia
2018-08-27 08:21:40 +02:00
committed by Aaron Bohy
parent 8bda4744b5
commit 3c9aa50449
2 changed files with 24 additions and 1 deletions
@@ -313,7 +313,7 @@ return AbstractRenderer.extend({
};
}
data_dict[serie].values.push({
x: tick, y: this.state.data[i].value,
x: tick - 1, y: this.state.data[i].value,
});
data = _.map(data_dict, identity);
}
@@ -154,6 +154,29 @@ QUnit.module('Views', {
});
});
QUnit.test('displaying line chart data with multiple groupbys', function (assert) {
// this test makes sure the line chart shows all data labels (X axis) when
// it is grouped by several fields
assert.expect(3);
var graph = createView({
View: GraphView,
model: 'foo',
data: this.data,
arch: '<graph type="line"><field name="foo" /></graph>',
groupBy: ['product_id', 'bar'],
});
assert.strictEqual(graph.$('.nv-x text:contains(xphone)').length, 1,
"should contain a text element with product xphone on X axis");
assert.strictEqual(graph.$('.nv-x text:contains(xpad)').length, 1,
"should contain a text element with product xpad on X axis");
assert.strictEqual(graph.$('text:contains(true)').length, 1,
"should have an entry for each value of field 'bar' in the legend");
graph.destroy();
});
QUnit.test('switching measures', function (assert) {
var done = assert.async();
assert.expect(4);