Currently, I am facing an issue with displaying dates properly on the x-axis of a graph created using Highcharts. To solve this problem, I need to parse the dates from the JSON response. Despite my attempts to manipulate the JSON date, I have not been able to achieve the desired outcome.
This is the current JSON response
"linechart":[{
"name":"Average Conversation Length (In minutes)",
"data":[["2020,02,12",12],["2020,02,13",13]]
},{
"name":"Average Number of Conversations",
"data":[["2020,02,12",10],["2020,02,13",21]]
}]
The expected output should be as follows:
linechart: [{name: "Average Conversation Length (In minutes)",
data: [[Date.UTC(2020, 02, 12), 12],[Date.UTC(2020, 02, 13), 13]]},
{name: "Average Number of Conversations",
data: [[Date.UTC(2020, 02, 12), 10],[Date.UTC(2020, 02, 13), 21]]}],
Here is what I have tried so far:
var arr1 = [];
var data = chartdata.linechart
for (var i = 0; i < data.length; i++){
var obj = data[i];
for (var key in obj){
var value = obj[key];
for (var value2 in value){
var values = value[value2];
arr1.push(Date.parse(values));
}
}
}