FIX: prepare data before creating chart to avoid side effect (#16570)

Before this change, we were using the labels from the original chartData to the chart builder, and we would then apply our collapse function on each dataset which could change the labels and cause a mismatch.

This was very visible when using quarterly periods on consolidated pageviews.
This commit is contained in:
Joffrey JAFFEUX 2022-04-27 14:04:09 +02:00 committed by GitHub
parent 1acc4751ff
commit 3e23bd4745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -54,7 +54,13 @@ export default Component.extend({
const context = chartCanvas.getContext("2d");
const chartData = makeArray(model.get("chartData") || model.get("data"));
const chartData = makeArray(model.chartData || model.data).map((cd) => {
return {
label: cd.label,
color: cd.color,
data: Report.collapse(model, cd.data),
};
});
const data = {
labels: chartData[0].data.mapBy("x"),
@ -62,7 +68,7 @@ export default Component.extend({
return {
label: cd.label,
stack: "pageviews-stack",
data: Report.collapse(model, cd.data),
data: cd.data,
backgroundColor: cd.color,
};
}),