title: How to get maximum value from an array of objects to use in d3.scale.linear().domain()
body: <p>I have an external csv file with data in columns like so:</p>
  
  <pre><code>name, field_goal_attempts, field_goal_makes
  </code></pre>
  
  <p>I am trying to use a linear scale but am encountering difficulty getting the maximum value for my domain.</p>
  
  <pre><code>var yScale = d3.scale.linear()
                 .domain(0, d3.max(...
  </code></pre>
  
  <p>I am confused as to:</p>
  
  <p>1) Whether I should put the yScale function outside or inside the </p>
  
  <pre><code>d3.csv("filename.csv", function(data) {
  </code></pre>
  
  <p>callback function; and </p>
  
  <p>2) How to get the maximum value of items in the field_goal_attempts column to then feed into the yScale function.</p>
  
  <p>Here is my code at present:</p>
  
  <pre><code>var yScale = d3.scale.linear()
      .domain([0, 4000]) //d3.max(data, function(d) {return d })])
      .range([0, 500]);
  
  d3.csv("test.csv", function (data) {
      svg.selectAll("rect")
          .data(data)
          .enter()
          .append("rect")
          .attr("fill", "blue")
          .attr("x", magic_number) // I'm not concerned about the magic numbers at this point :)
          .attr("y", 0)
          .attr("width", another_magic_number)
          .attr("height", function (d) {
              return d.field_goal_attempts
          })
          .attr("id", function (d, i) {
              return i
          });
  });
  </code></pre>