title: Formatting JSON for C3.js
body: <p>I have a specific JSON output that I need to convert into x and y-axis for a C3.js line graph but it doesn't seem to like the way it's currently formatted:</p>
  
  <pre><code>{
      "results": [
          {
              "param": "x",
              "val": [
                  1,
                  2,
                  3,
                  4
              ]
          },
          {
              "param": "y",
              "val": [
                  2,
                  3,
                  5,
                  6
              ]
          }
      ]
  }
  </code></pre>
  
  <p>What the best way to transform this (using JS) so that it can be read by C3.</p>
  
  <p>Ultimately I'm going to upload multiple xy line charts so I'm guessing it's going to have to be something like <a href="http://c3js.org/samples/simple_xy_multiple.html" rel="noreferrer">this sample code</a>, but instead pulling it from json:</p>
  
  <pre><code>var chart = c3.generate({
      data: {
          url: '/sampleJSON',
          mimeType: 'json',
          xs: {
              'param-y': 'param-x',
              'data2': 'x2', //not sure how to name these ones differently on load, but this is a different issue
          },
          columns: [
              ['param-x', 1, 2, 3, 4],
              ['param-y', 2, 3, 5, 6],
              ['x2', 30, 50, 75, 100, 120], //again just placeholder to eventually have other data
              ['data2', 20, 180, 240, 100, 190] //again just placeholder to eventually have other data
          ]
      }
  });
  </code></pre>