title: d3 convert x axis from array indices to dates
body: <p>I have a data that is an array of values, like this:</p>
  
  <pre><code>[244, 13, 24, 0, 18, 24, 3, 4, ... ]
  </code></pre>
  
  <p>While array indices are simply integers, in this data they represent a range of dates such that the 0th index represents, say, <code>06/04/2013</code> and the last index represents <code>09/30/2013</code> although they're actually in seconds since 1970, so <code>1370378409</code> and <code>1380575923</code> would be more precise.</p>
  
  <p>I would like my x-axis to show the dates that the array indices represent.  So that the ticks would look like dates: <code>Mon 08</code>, <code>Tue 09</code> and so on.  As the data will change, I cannot know what the ticks should be ahead of time.. I'm hoping they can be calculated from the endpoints which I do know.</p>
  
  <p>Theoretically, I'm thinking that I can convert from the domain of the x-axis (the chart's width) to the date range represented in the array.  Something like this (but this didn't work in this formulation):</p>
  
  <pre><code>var xAsTime = d3.time.scale()
                   .domain([0, width])
                   .range([startDate, endDate])
  </code></pre>
  
  <p>which should nicely translate from integers to dates.</p>