1👍
✅
If I understood correctly, this is what you mean;
If you have created chartData, you can acces the dataset as follows:
chartData = {
datasets: [{
yAxisID: "funding",
label: "Credorax DK Funding",
data: [],
position: "left",
},
{
yAxisID: "release",
label: "Credorax DK Release",
data: [],
position: "right",
}
,//other config, etc...
};
//init chart with this config
var ctx = document.getElementById("likviditetChart").getContext("2d");
var chart = new Chart(ctx, chartData);
//itterate your data and add it to the datasets
for (var i = 0; i < CredoraxDK.length;i++){
chartData.datasets[0].data.push({
y: CredoraxDK[i].y,
x: CredoraxDK[i].x});
chartData.datasets[1].data.push({
y: CredoraxDK[i].y2,
x: CredoraxDK[i].x});
}
//update new data.
chart.update();
So basically, you set up the chart config first, and add the chart-data to the data array later.
Don’t forget to call the chart.update();
function when you are done.
Source:stackexchange.com