Currently, I am working on generating graphs using d3.js with a JSON file as the input. My main challenge lies in parsing the date and time format for the x-axis. Below is the code snippet that I have attempted:
d3.json('data/fake_users11.json', function(data) {
var parseDate = d3.time.format("%Y-%m-%d %H:%M:%S").parse;
var old = JSON.stringify(data).replace(/\//g, "-");
data = JSON.parse(old); //convert back to array
data.forEach(function(d) {
d.date = parseDate(d.date);
});
The structure of the JSON file looks similar to this:
[
{
"date": "02\/18\/2016 18:02:38",
"value": 10
},
{
"date": "02\/18\/2016 18:02:45",
"value": 20
},
{
"date": "02\/18\/2016 18:02:50",
"value": 30
}
]
My goal is to achieve the format "02-18-2016 18:02:50", however, I keep running into errors. I feel like I am very close to the solution but missing something critical. Could someone please help me identify the mistake here? Your assistance is greatly appreciated.