title: Merging multiple series in d3
body: <p>I have multiple data series in an array like this :</p>
  
  <pre><code>[
      {
          "key": "series1",
          "values": [
              {
                  "x": 1378405800000, "y": 0
              },
              {
                  "x": 1378407600000, "y": 0
              },
              ...
          ]
      },
      {
          "key": "series2",
          "values": [
              {
                  "x": 1378405800000, "y": 0
              },
              {
                  "x": 1378407600000, "y": 0
              },
              ...
          ]
      },
      ..
  ]
  </code></pre>
  
  <p>I use the following to merge them :</p>
  
  <pre><code>var t = {};
  var o = data2; //above data structure
  
  for( srs = 0; srs &lt; o.length; srs++ )
  {
          key = o[srs]['key'];
          for ( ele = 0; ele &lt; o[srs]['values'].length; ele++ )
          {
                  mykey = o[srs]['values'][ele]['x'];
                  if (!t.hasOwnProperty(mykey))
                  t[mykey] = {};
                  t[mykey]['x'] = o[srs]['values'][ele]['x'];
                  t[mykey][key] = o[srs]['values'][ele]['y'];
          }
  }
  
  var multseries = [];
  for (ele in t)
  multseries.push(t[ele]);
  </code></pre>
  
  <p>Q1 Is this possible via d3.js API, using map or nest ? </p>
  
  <p>Q2 Is there a better way to do this with or without d3.js? This will go through each element of all series once, but one series at a time. Is it possible to merge in order of x (fetch and merge elements x-wise). Also what if some elements are missing in a series.</p>