title: How do I display dates on the x-axis for nvd3 / d3.js?
body: <p>I'm using nvd3, but I think this is a general d3.js question about time scale and formatting. I've created a simple example that illustrates the problem (see code below):</p>
  
  <p>If I omit .tickFormat for the xAxis, it works fine without date formatting.  With the example below I get the error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Object 1326000000000 has no method 'getMonth'</p>
  </blockquote>
  
  <pre><code>nv.addGraph(function() {
  
      var chart = nv.models.lineChart();
  
      chart.xAxis
           .axisLabel('Date')
           .rotateLabels(-45)
           .tickFormat(d3.time.format('%b %d')) ;
  
       chart.yAxis
           .axisLabel('Activity')
           .tickFormat(d3.format('d'));
  
       d3.select('#chart svg')
           .datum(fakeActivityByDate())
         .transition().duration(500)
           .call(chart);
  
       nv.utils.windowResize(function() { d3.select('#chart svg').call(chart) });
  
       return chart;
  });
  
  function days(num) {
      return num*60*60*1000*24
  }
  
  /**************************************
   * Simple test data generator
   */
  
  function fakeActivityByDate() {
      var lineData = [];
      var y = 0;
      var start_date = new Date() - days(365); // One year ago
  
      for (var i = 0; i &lt; 100; i++) {
          lineData.push({x: new Date(start_date + days(i)), y: y});
          y = y + Math.floor((Math.random()*10) - 3);
      }
  
      return [
          {
              values: lineData,
              key: 'Activity',
              color: '#ff7f0e'
          }
      ];
   }
  </code></pre>
  
  <p>The example (now fixed) is in <em><a href="http://ultrasaurus.github.com/nvd3-simpleline/date_axis.html" rel="noreferrer">nvd3 with date axis</a></em>.</p>