I would like to know how to make a for loop to dynamically fill parameters in the following code:
data: [{
type: "pie",
startAngle: 25,
toolTipContent: "<b>{label}</b>: {y}%",
showInLegend: "true",
legendText: "{label}",
indexLabelFontSize: 16,
indexLabel: "{label} - {y}%",
dataPoints: [{
y: parseFloat(result.valor[0]),
label: result.nombres[0]
}, {
y: parseFloat(result.valor[1]),
label: result.nombres[1]
}, {
y: parseFloat(result.valor[2]),
label: result.nombres[2]
}, {
y: parseFloat(result.valor[3]),
label: result.nombres[3]
}, {
y: parseFloat(result.valor[4]),
label: result.nombres[4]
}, {
y: parseFloat(result.valor[5]),
label: result.nombres[5]
}, {
y: parseFloat(result.valor[6]),
label: result.nombres[6]
}, {
y: parseFloat(result.valor[7]),
label: result.nombres[7]
}]
}]
});
The idea is that y: parseFloat (result.valor [i]), label: result.nombres [i];
Generated automatically without having to enter the parameters