title: How populate chart.js with sql data?
body: <p>I'm using chart.js to generate charts on my page.
  However I want these charts to be populated by my SQL database.
  I'm able to get my data out of my database, but I won't draw the chart</p>
  
  <p>I got a canvas on my main page called "OmzetChart" , this is where the chart should come.</p>
  
  <pre><code>&lt;script&gt;
      $.ajax({
          type: 'POST',
          url: 'templates/getdata.php',
          success: function (data) {
              lineChartData = data;
              //alert(JSON.stringify(data));
  
              var ctx = document.getElementById("OmzetChart").getContext("2d");
              var myLineChart = new Chart(ctx, {
                  type: 'line',
                  data: lineChartData
  
              });
         }
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The page of GetData.php results in the following (This is what I need, just want it into my chart): </p>
  
  <pre><code>[{"dag":"23","0":"23","uur":"13","1":"13","SomOmzet":"23.00","2":"23.00"},{"dag":"23","0":"23","uur":"18","1":"18","SomOmzet":"2.50","2":"2.50"}]
  
  Getdata.php: 
  &lt;?php
  include ("../PDO.php");
  
  
  $conn = DatabasePDO::getInstance();
  $sql = "SELECT DATEPART(DD, receiptdatetime) as dag ,DATEPART(hh, receiptdatetime) as uur, ISNULL(abs(cast(sum(NetAmount) as decimal (10,2))),0) as SomOmzet FROM ReceiptLine a , Receipt b, ReceiptLineDetail c 
  where a.LineType = 200 and a.receiptID = b.receiptid and a.receiptlineID = c.receiptlineID
  group by DATEPART(DD, receiptdatetime), DATEPART(hh, receiptdatetime)";
  $st = $conn-&gt;prepare($sql);
  $st-&gt;execute();
  $list = array();
  
  while ( $row = $st-&gt;fetch() ) {
      $list[] = $row;
  
  }
  $conn = null;
  
  echo json_encode( $list );
  
  ?&gt;
  </code></pre>