I would like to reduce the amount of data to be charted. I have data with duplicate dates in an array of arrays.
How to keep only items with a single date?
I would like to have one array per day, the structure looks like this:
[
[
"date",
"amount",
"code"
],
[
"2022-08-18",
4652,
"AAA"
],
[
"2022-08-18",
491783,
"BBB"
]
[
"2022-08-19",
515501,
"AAA"
],
[
"2022-08-19",
15953,
"BBB"
],
[
"2022-08-19",
15953,
"CCC"
]
]
I tried
temp1.filter((e, index)=> {
if (index<temp1.length-1) {
return e[0]==temp1[index+1][0] ? e : null
} else {
return e
}
})
But this only removes the last element before the new date (I shifted first index ofc).