6π
β
it is not displaying because it cannot find labels2, change below
const data2 = {
labels : labels2, //change here
datasets: [
{
data: [211, 326, 165, 350, 420, 370, 500, 376, 415],
label: 'Title',
fill: true,
backgroundColor: gradient,
borderColor: '#6935D3',
pointBackgroundColor: '#4D1BB1',
},
],
};
3π
You have to use "labels: labels2".
If you only use the variable, the variable name is automatically used as property name.
const data2 = {
labels: labels2,
datasets: [
{
data: [211, 326, 165, 350, 420, 370, 500, 376, 415],
label: 'Title',
fill: true,
backgroundColor: gradient,
borderColor: '#6935D3',
pointBackgroundColor: '#4D1BB1',
},
],
};
Source:stackexchange.com