Not Understanding Result Of D3.timeparse?
I'm having trouble understanding how d3.timeParse works. I initialize the function at the beginning like this: var dateParse = d3.timeParse('%Y-%m-%d'); I then call it here: d3.js
Solution 1:
Use timeFormat, and wrap d.date to new Date(d.date):
var dateParse = d3.timeFormat("%Y-%m-%d");
var data = [{
"date": "2017-01-04",
"open": 10430.69
}, {
"date": "2017-01-05",
"open": 10584.56
}];
data.forEach(function(d) {
d.dd = dateParse(newDate(d.date));
console.log(d.dd);
});<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script>
Post a Comment for "Not Understanding Result Of D3.timeparse?"