I created a graph using NextJs and ChartJs to display the COVID-19 statistics over the past 30 days. I retrieved this data from an API that provides information such as dates and stats:
timeline: {
cases: {
'5/13/21': 5902343,
'...' : ...
},
}
The graph is working, but I want to display the date for each stat on the X-axis of my chart.
This is the code I used (lineData represents my API request):
labels: [Object.keys(lineData.timeline.cases)],
However, it's showing all the dates as a single object.
Currently, my label looks like this:
labels: [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
],
My goal is to replace these numerical values with the actual dates provided by the API.