I get all the values of expirationdate and price in the loop. How do I write them to a variable and how do I specify them in labels: [],data: []?
success: function (data) {
if (data.result) {
for (let i = 0; i < data.result.length; i++) {
console.log(data.result[i].expirationdate);
console.log(data.result[i].price);
}
var ctx = document.getElementById("myChart").getContext("2d");
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'Payment',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [],
}]
},
options: {}
});
}
}
expirationdateto fill thelabelsproperty, andpriceto fill thedataproperty? If not, please edit your question to better explain.