title: Nested arrays in JSON with D3
body: <p>I'm new with d3js and am trying to plot a line from an array nested in a JSON. Few questions on the topic have already been asked but their solutions don't work for my specific problem (maybe it's just me being a total novice though). </p>
  
  <p>The JSON file (json_data.json) in question is this: </p>
  
  <pre><code>{"Test": 1, 
   "Name": "SampleA", 
   "Voltage": [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1], 
   "Current": [-0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5]}
  </code></pre>
  
  <p>"Voltage" and "Current" are the x and y values I want to plot with this js:</p>
  
  <pre><code>var margin = {top: 50, right: 50, bottom: 50, left: 50},
      width = 800 - margin.left - margin.right,
      height = 600 - margin.top - margin.bottom;
  
  var xScale = d3.scaleLinear().range([0, width]);
  var yScale = d3.scaleLinear().range([height, 0]);
  
  var xAxis = d3.axisBottom().scale(xScale);
  var yAxis = d3.axisLeft().scale(yScale);
  
  var line = d3.line()
      .x(function(d,i){return d.Voltage[i]; } )
      .y(function(d,i){return d.Current[i]; } );
  
  var svg = d3.select("body")
      .append("svg")
          .attr("width", width + margin.left + margin.right)
          .attr("height", height + margin.top + margin.bottom)
      .append("g")
          .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
  
  d3.json("json_data.json", function(data) {
  
  xScale.domain(d3.extent(data.Voltage));
  yScale.domain(d3.extent(data.Current));
  
  svg.append("path")     
      .attr("d", line(data))
  
  svg.append("g")       
      .attr("class", "x axis")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);
  
  svg.append("g")        
      .attr("class", "y axis")
      .call(yAxis);
  
  });
  </code></pre>
  
  <p>The problem is that for some reason the line chart is not displayed. The axes are shown with the correct scale which makes me think there must be an issue with the line() generator. The JSON and the nested arrays show up when I run console.log.</p>
  
  <p>I'd really appreciate your help! And if you have any suggestions on how to improve my code or JSON structure I'm listening :) Thanks a lot!</p>