0
FROM THE RESULT OF THE CALL TO THE API I HAVE THAT RESULT:
var origemApi = [
{ data: '23-04', tipo: 'ADP' },
{ data: '23-04', tipo: 'IDP' },
{ data: '23-04', tipo: 'ADP' },
{ data: '23-05', tipo: 'ADP' },
{ data: '23-05', tipo: 'IDP' },
{ data: '23-05', tipo: 'ADP' },
{ data: '23-06', tipo: 'IDP' },
{ data: '23-06', tipo: 'ADP' },
{ data: '23-06', tipo: 'IDP' },
{ data: '23-06', tipo: 'IDP' },
{ data: '23-06', tipo: 'ADP' }
]
No Vue using groupBy and having achieved this result:
var destinoFront = [
{ data: '23-04', tipo: 'ADP', total: '10' },
{ data: '23-04', tipo: 'IDP', total: '20' },
{ data: '23-05', tipo: 'ADP', total: '30' },
{ data: '23-06', tipo: 'ADP', total: '15' },
{ data: '23-06', tipo: 'IDP', total: '15' }
]
that is, I grouped by type and date and calling SUM managed to generate the total It turns out that in index 3 (date 23-04), I only have type ADP of total 30 of a total of 30 records therefore, I DO NOT HAVE other index idp with total 0 type:
var destinoFront = [
{ data: '23-04', tipo: 'ADP', total: '10' },
{ data: '23-04', tipo: 'IDP', total: '20' },
{ data: '23-05', tipo: 'ADP', total: '30' },
{ data: '23-05', tipo: 'IDP', total: '0' },
{ data: '23-06', tipo: 'ADP', total: '15' },
{ data: '23-06', tipo: 'IDP', total: '15' }
]
need perhaps with splice push an index that is missing because I need to ALWAYS on the same date have 2 TYPES (ADP and IDP) to power some graphics that need a date where I have two data for the x and y axes.
It happens that in the API of a total of 30 records, if all are ADP(or vice versa) the IDP as it does not exist at that date, the query does not return me IDP 0. That’s the part of the problem...
Supposing I got this, now you need to count the two guys in a single kind:
var primeiroProblemaResolvido = [
{ data: '23-04', tipo: 'ADP', total: '10' },
{ data: '23-04', tipo: 'IDP', total: '20' },
{ data: '23-05', tipo: 'ADP', total: '30' },
{ data: '23-05', tipo: 'IDP', total: '0' },
{ data: '23-06', tipo: 'ADP', total: '15' },
{ data: '23-06', tipo: 'IDP', total: '15' }
]
var resultadoFinalEsperado = [
['23-04', '10', '20']
['23-05', '30', '0']
['23-06', '15', '15'] // ou seja, um aaray com a data, o tipo ADP e o tipo IDP(apenas os valores
]
Already try everything using map and filter with push and splice but when I solve the first problem, the second gets lost and vice versa.
I cannot format this text correctly...
– sidiara castro