I am getting
Uncaught TypeError: Cannot read property 'length' of undefined
from my console at this line
var parseDate = d3.time.format("%Y-%m-%d").parse;
data.forEach(function(d) {
d.Day = parseDate(d.Day);
});
here is how my date is formatted in my json object day: "2013-02-04"
I am getting
Uncaught TypeError: Cannot read property 'length' of undefined
from my console at this line
var parseDate = d3.time.format("%Y-%m-%d").parse;
data.forEach(function(d) {
d.Day = parseDate(d.Day);
});
here is how my date is formatted in my json object day: "2013-02-04"
-
Can you try using an alternative approach stackoverflow./questions/2587345/javascript-date-parse ? I usually use something like
Date(Date.parse("2005-07-08"));
. – user1477388 Commented Feb 4, 2013 at 17:54 - Sounds like the error message is ing from somewhere else. Can you post a plete minimal example? – Lars Kotthoff Commented Feb 4, 2013 at 18:38
- Is the lowercase 'day' in the object a mistake? Or is it supposed to be 'Day' as in the reference? – cmonkey Commented Feb 4, 2013 at 18:47
- yeah, this was correct @cmonkey it was supposed to be lowercase day. I have another problem now – CQM Commented Feb 4, 2013 at 18:51
1 Answer
Reset to default 6I suspect the case of 'day' is incorrect. I can execute:
var parseDate = d3.time.format("%Y-%m-%d").parse;
parseDate( "2013-02-03" )
Without issue (it shows the correct Date). Likely, you need to change the code to:
data.forEach(function(d) { d.day = parseDate(d.day); });
(note, lowercase 'd' in 'day')