I have the following data object
var data = {
labels: ["2013", "2014", "2015", "2016"],
datasets: [
{
label: "Label 1",
data: data1,
},
{
label: "Label 2",
data: data2,
}
]
};
I want to get the second label "Label 2".
I have tried to use
console.log(data.datasets[0].label); // Only returns Label 1
console.log(data.datasets[0][1].label); // Doesn't work
I don't want to make changes on the structure as I am using it with Chart.js to draw charts.
Thanks in advance.
console.log(data.datasets[1].label);..?