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:
parent
1acc4751ff
commit
3e23bd4745
|
@ -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,
|
||||
};
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue