title: D3 linegraph using JSON data from API
body: <p>I am working on making a linegraph in D3 that displays data in JSON format that is retrieved from an API.</p>
  
  <p>I found an <a href="https://bl.ocks.org/mbostock/3883245" rel="nofollow noreferrer">example </a>line graph project on D3's website and it seems relatively straight forward. The main difference between the example and my project is that the example uses data from a local csv file instead of JSON from an API request. </p>
  
  <pre><code>// This needs to be changed to my API request
  d3.tsv("data.tsv", function(d) {
    d.date = parseTime(d.date);
    d.close = +d.close;
    return d;
  }, function(error, data) {
    if (error) throw error;
  
    x.domain(d3.extent(data, function(d) { return d.date; }));
    y.domain(d3.extent(data, function(d) { return d.close; }));
  
    g.append("g")
        .attr("transform", "translate(0," + height + ")")
        .call(d3.axisBottom(x))
      .select(".domain")
        .remove();
  
    g.append("g")
        .call(d3.axisLeft(y))
      .append("text")
        .attr("fill", "#000")
        .attr("transform", "rotate(-90)")
        .attr("y", 6)
        .attr("dy", "0.71em")
        .attr("text-anchor", "end")
        .text("Price ($)");
  
    g.append("path")
        .datum(data)
        .attr("fill", "none")
        .attr("stroke", "steelblue")
        .attr("stroke-linejoin", "round")
        .attr("stroke-linecap", "round")
        .attr("stroke-width", 1.5)
        .attr("d", line);
  });
  </code></pre>
  
  <p>I changed the csv request part to this because I'm trying to load in my JSON from the API:</p>
  
  <pre><code>    d3.json(url).get(function(d) {
      for(var i = 0; i &lt; d.Data.length; i++) {
        coinValue.push(d.Data[i].close);
        dates.push(convertUnixTime(d.Data[i].time));
      }
      return d;
    }, function(error, data) {
    if (error) throw error;
  </code></pre>
  
  <p>This isn't working. I'm confused about why there's a comma and then another function right after.</p>
  
  <p>What is the proper way to make the exact same line graph but with a d3.json function/API request instead?</p>
  
  <p>My JSON looks like this: <a href="https://min-api.cryptocompare.com/data/histoday?fsym=ETH&amp;tsym=USD&amp;limit=2&amp;aggregate=3&amp;e=CCCAGG" rel="nofollow noreferrer">https://min-api.cryptocompare.com/data/histoday?fsym=ETH&amp;tsym=USD&amp;limit=2&amp;aggregate=3&amp;e=CCCAGG</a></p>