title: Parsing JSON data into specific format for chart.js
body: <p>I'm trying to use <code>Chart.js</code> to generate a pie chart using dynamically generated data. I'm having trouble getting the data in the right format, I think I'm close but I've been stuck for a while.</p>
  
  <p><strong>I'm using ajax to get JSON data like this:</strong></p>
  
  <pre><code>$.ajax({
      url: '../helpdesk/getTicketsPerSubcat/' + startDate + '/' + endDate + '/' + activeLabel,
      dataType: 'JSON',
      success: function(result){
          var pieData = new Array();
  
          // populate array
          for (i in result) {
              var foo = {value: result[i].total, label: result[i].subcategory}
              var jsonString = JSON.stringify(foo);
              pieData.push(jsonString);
          }
          console.log(pieData);
      }
  });
  </code></pre>
  
  <p><strong>Which returns:</strong></p>
  
  <pre><code>["{"value":"2","label":"Disk Space"}", "{"value":"1","label":"Performance Issue"}"]
  </code></pre>
  
  <p><strong>This is what the documentation says the data needs to look like:</strong></p>
  
  <pre><code>var data = [
      {
          value: 300,
          label: "Red"
      },
      {
          value: 50,
          label: "Green"
      },
      {
          value: 100,
          label: "Yellow"
      }
  ]
  </code></pre>
  
  <p>I seem to have those extra quotes just inside the square brackets which must be what is causing an error (<code>Uncaught TypeError: Cannot read property 'length' of undefined</code>). Is <code>JSON.stringify()</code> the wrong function to be using? Any help would be very much appreciated!</p>