title: Displaying JSON data in Chartjs
body: <p>I am trying to use <a href="http://www.chartjs.org/" rel="noreferrer">Chart JS</a> to create a table with dynamically generated data points coming from my JSON file. The logic of my code looks like so:</p>
  
  <pre><code>var datapart;
  for (i = 0; i &lt; jsonfile.jsonarray.length; i++){
       datapart += {
            label: jsonfile.jsonarray[i].name,
            data: [jsonfile.jsonarray[i].age] 
       };
  }
  
  var config = {
     type: 'line',
     data: {
        labels: ["Graph Line"],
        datasets: [datapart]
     }
  }
  </code></pre>
  
  <p>My JSON file meanwhile looks something like so: </p>
  
  <pre><code>{
  "jsonarray": [
      {
        "name": "Joe",
        "age": 12
      },
      {
        "name": "Tom",
        "age": 14
      }
  ]
  }
  </code></pre>
  
  <p>The <code>config</code> variable houses the configuration settings for ChartJS, including setting datapoints. When loaded into ChartJS, <code>config</code> provides information needed to display my chart. </p>
  
  <p>Anyhow, my thinking was to use the variable <code>datapart</code> as a means of appending the datasets using my for loop. Unfortunately the code produces no results. I understand that my method for appending variables is faulty, but am unsure how to proceed. </p>
  
  <p>How might I go about adding these JSON values to Chart.js?</p>