I want to filter two objects in datasets array by label with date . I use in react-chartjs-2. I don't know how do i filter.
Example :
First Object : {
"id": 2,
"customer_id": 4,
"date": "2019-05-15T21:00:00.000Z",
"wbc": 15,
"vitamin": 14
}
Second Object : {
"id": 3,
"customer_id": 4,
"date": "2022-05-22T21:00:00.000Z",
"wbc": 20,
"vitamin": 5
}
I need to this :
datasets: [
{
label: "WBC",
data: [
{ x: "2019-05-15", y: 15 },
{ x: "2022-05-22", y: 20 },
],
backgroundColor: "#003f5c",
pointRadius: 8,
pointHoverRadius: 8,
},
{
label: "Vitamin",
data: [
{ x: "2019-05-15", y: 14 },
{ x: "2022-05-22", y: 5 },
],
backgroundColor: "#ffa600",
pointRadius: 8,
pointHoverRadius: 8,
},
],