3
I have the following script:
var data = JSON.parse( '<?php echo json_encode($lista_tipo_indicadores) ?>' );
var cores = JSON.parse('<?php echo json_encode($cores) ?>');
// Quantidade de Indicadores por Tipo
var doughnutData = [
{
value: data[0].total,
color:cores[0],
highlight: "#FF5A5E",
label: data[0].nome
},
{
value: data[1].total,
color: cores[1],
highlight: "#5AD3D1",
label: data[1].nome
},
{
value: data[2].total,
color: cores[2],
highlight: "#FFC870",
label: data[2].nome
},
{
value: data[3].total,
color: cores[3],
highlight: "#5AD3D1",
label: data[3].nome
},
{
value: data[4].total,
color: cores[4],
highlight: "#FFC870",
label: data[4].nome
},
{
value: data[5].total,
color: cores[5],
highlight: "#5AD3D1",
label: data[5].nome
},
{
value: data[6].total,
color: cores[6],
highlight: "#FFC870",
label: data[6].nome
},
{
value: data[7].total,
color: cores[7],
highlight: "#FFC870",
label: data[7].nome
}
];
How do I make the variable to be generated dynamically, with some foreach?
Confirm that I understand correctly, you want to fill in the doughnutData variable by foreach instead of having to do it manually?
– Felipe Assunção
What is the relationship between date and colors and Highlight? Colors come from the I imagine array, but both have the same number of elements?
– Sergio