I am using d3 in an Angular 5 app to graph a line, and I can't seem to get my numbers right. I'm getting this error:
Error: <path> attribute d: Expected number, "MNaN,25.384615384…".
I assume it's either something to do with how I'm parsing my dates, or date type, or the domain on my axis?
The d3 code in question looks like:
var x = d3.scaleLinear()
.range([0, width - 100])
.domain(<[Date, Date]>d3.extent(this.temp_data, function (d) { return parse(d['date']); }));
var xAxis = d3.axisBottom(x)
.scale(x)
.ticks((width + 2) / (height + 2))
.tickSize(-height)
.tickPadding(10)
.tickFormat(d3.timeFormat("%b %d, %H:%M:%S"))
var parseTime = d3.timeParse("%Y-%m-%dT%H:%M:%S.%LZ");
var line = d3.line()
.x(function (d) { return x(parseTime(d['date'])); })
.y(function (d) { return y(d['temperature']); });
My data looks like in UTC format:
[{"temperature": "11.0", "date": "2018-10-10 20:36:27 UTC" }.
{"temperature": "11.2", "date": "2018-10-10 20:34:27 UTC" },
{"temperature": "10.9", "date": "2018-10-10 20:32:27 UTC" },
{"temperature": "11.3", "date": "2018-10-10 20:30:27 UTC" },
{"temperature": "11.0", "date": "2018-10-10 20:28:27 UTC" }]
Where might that error be coming from? Thanks! Any help or thoughts are greatly appreciated!
EDIT:
I know this is slightly different code but I am having the same problem on this codepen HERE.
thanks so much! I've been starting at it too long now and am starting to go in circles