title: How can I efficiently convert data from string to int within a d3 method chain?
body: <p>I'm making an interactive bar chart in d3, and have come across a problem. The bar chart reads data from a form, but it reads the data as a string. When I am using the data to draw bars like this:</p>
  
  <pre><code>var bars = svg.selectAll("rect")
      .data(dataset)
      .enter()
      .append("rect")
      .attr("x", function(d,i) {
          return i * (w / dataset.length);
      })
      .attr("y", function(d) {
          return h - (d * 4);
      })
      .attr("width", w / dataset.length - barPadding)
      .attr("height", function(d) {
          return d * 4;
      })
      .attr("fill", function(d) {
          return "rgb(" + (d * redLevel) + ", 0, " + (d * blueLevel) + ")";
      });
  </code></pre>
  
  <p>the data is read as a string. I could use <code>parseInt(d)</code> every time I wanted to use <code>d</code>, but that would be grossly inefficient. It would be easy to do <code>var d = parseInt(d)</code> outside of the method chain, but that wouldn't work with d3. Suggestions?</p>