0👍
✅
That for-loop never gets beyond the first iteration because the body contains a return
. To return an array resulting from all iterations, create an array variable, push to it in the loop, then return that array…
datasets: function() {
let labelObjects = [];
let dataset = courbeSatisfactionserv.dataset; // easier on the eyes
for (let i = 0; i < (dataset.size); i++) {
let labelObject = {
datalabels: {
display: false,
},
label: JSON.parse(dataset[`points_lab_${i}`]),
data: JSON.parse(dataset[`points_${i}`]),
fill: false,
borderColor: '#442B48',
backgroundColor: '#442B48',
borderWidth: 2
}
labelObjects.push(labelObject);
}
return labelObjects;
}
Source:stackexchange.com