D3 v4 returning error for scaleTime when passing in Date object
<p>I am trying to create a simple bar chart where the x axis is formatted with dates. I have defined my x like so, </p>

<pre><code>var minDate = new Date(data[0][0]);
var maxDate = new Date(data[274][0]);

var x = d3.scaleTime()
          .domain(minDate, maxDate).range([0, width]);
</code></pre>

<p>However, I get an error when I try to call this from my chart </p>

<pre><code>chart.selectAll('.bar')
         .data(data)
         .enter().append('rect')
         .attr('class', 'bar')
         .attr('x', function(d){
          return x(new Date(d[0]));
         })
</code></pre>

<p>The error says </p>

<blockquote>
  <p>Error:  attribute x: Expected length, "NaN".</p>
</blockquote>

<p>Not really sure what I'm doing wrong. Do date objects still work in D3 v4 with a scaleTime? </p>

<p>Here is a link to the dataset if anyone wants to take a look
<a href="https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/GDP-data.json" rel="nofollow noreferrer">https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/GDP-data.json</a></p>

<p>Here is a link to the codepen where I am working on this</p>

<p><a href="http://codepen.io/redixhumayun/pen/ZBdmQp?editors=0010" rel="nofollow noreferrer">http://codepen.io/redixhumayun/pen/ZBdmQp?editors=0010</a></p>