This is the json data I am pulling from the backend API:
[
{
"year": 2024,
"month": 7,
"revenue": 27000
},
{
"year": 2024,
"month": 8,
"revenue": 27000
}
]
However in order to use nivo line charts to graph the data the data must be in the following format.
Array<{
id: string | number
data: Array<{
x: number | string | Date
y: number | string | Date
}>
}>
I can manipulate the data on the backend but I’m having a hard time figuring out whether it’s easier to manipulate the data via the frontend to arrange in this format.
2
Answers
I hacked away at decent way of getting the output that I need using kamran's code above as a starting point. However I think doing it on the backend is the best method moving forward.
i think you can do these:
`
and there is result: