I am putting a% of the total sales value per month. The code is working perfectly, but I need to array
check which months are not in this array and fill it in order 1 to 12. For example:
The code generated an array like this:
[{4: 3094}, {6: 9873}, {7: 6531}, {12: 10937}]
Then there are javascript
months.
I need the code to insert the other months 4, 6, 7 e 12
in this array with the value of 0 and leave in the order of months that are (1,2,3,5,8,9,10,11)
I have the code:
var resultadosOne = {};
var highchartsOne = [];
for (ano in resultadosOne) {
var mesVendaArray = [];
for(mes in resultadosOne[ano]){
var vendaMes = 0;
resultadosOne[ano][mes].forEach((venda) => {
VendaFormatada = venda.replace(",", ".");
if(VendaFormatada <= 0){
VendaFormatada = 0;
}
vendaMes += parseFloat(VendaFormatada);
});
mesVendaArray.push({mes:mes, venda: vendaMes});
};
if(ano != ""){
highchartsOne.push({name:ano, data:mesVendaArray, color:'#6AB241'});
}
};