title: rCharts nvd3 library force ticks
body: <p>I would like to force all tick marks and tick labels to appear along the axis in an <code>rCharts</code> nPlot from the <code>nvd3</code> library. I have tried several approaches without success.</p>
  
  <p>This is the default behaviour:</p>
  
  <pre><code>df &lt;- data.frame(x = 1:13, y = rnorm(13))
  library(rCharts)
  n &lt;- nPlot(data = df, y ~ x, type = 'lineChart')
  n$yAxis(showMaxMin = FALSE)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/JedGQ.png" alt="enter image description here"></p>
  
  <p>I would like to have all data in <code>1:13</code> show along the x axis.</p>
  
  <p>Ultimately, I have custom tickmarks I want to show <strong>equally-spaced</strong> with the following replacement:</p>
  
  <pre><code>n$xAxis(tickFormat = "#! function (x) { 
      ticklabels = ['0-1000', '1000-1500', '1500-1700', '1700-1820', '1820-1913', 
          '1913-1950', '1950-1970', '1970-1990', '1990-2012', '2012-2030', 
          '2030-2050', '2050-2070', '2070-2100']
          return ticklabels[x-1];
  } !#")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/iBKrC.png" alt="enter image description here"></p>
  
  <p>I hope it is clear why I want to have all tick marks and labels printed (and equally spaced).</p>
  
  <p>To give an idea of the finished product, here is a <code>ggplot2</code> impression:</p>
  
  <pre><code>library(ggplot2)
  df &lt;- data.frame(x = c('0-1000', '1000-1500', '1500-1700', '1700-1820', '1820-1913', 
      '1913-1950', '1950-1970', '1970-1990', '1990-2012', '2012-2030', '2030-2050', 
      '2050-2070', '2070-2100'), y = rnorm(13), z = "group1")
  ggplot(data = df, aes(x = x, y = y, group = z)) + geom_line()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/QKBKs.png" alt="enter image description here"></p>
  
  <p>Here are several things I have tried, based on several suggestions I found here and there: neither work. </p>
  
  <p>Based on my reading of the docs, I thought this would work:</p>
  
  <pre><code>n$xAxis(tickFormat = "#! function (x) {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13][x-1];
  } !#")
  </code></pre>
  
  <p>I also tried this, on the off chance:</p>
  
  <pre><code>n$xAxis(ticks = 13)
  </code></pre>
  
  <p>I also tried to combine <code>tickValues</code> and <code>tickFormat</code> but with no success.</p>
  
  <p>I also thought about writing a script, but again my understanding of the <code>nvd3</code> library was insufficient.</p>
  
  <pre><code>n$setTemplate(afterScript = 
      "&lt;script&gt;
          var chart = nv.models.lineChart();
          var newAxisScale = d3.scale.linear();
              .range(d3.extent(chart.axes[0]._scale.range()))
              .domain([1, d3.max(chart.axes[0]._scale.domain())])
          chart.axes[0].shapes.call(
              d3.svg.axis()
              .orient('bottom')
              .scale(newAxisScale)
              .ticks(13)
              //.tickValues()
              //.tickFormat(d3.format())
          ).selectAll('text')
            .attr('transform','')
      &lt;/script&gt;"
  )
  </code></pre>
  
  <p>None of these report errors in the console, but none of them modify the appearance of the first plot above.</p>