title: Morris.js Uncaught TypeError: Cannot read property 'match' of undefined
body: <p>I am losing my mind on this and can't figure out the issue. I am using the following code to render a chart using morris.js and I keep getting a "Uncaught TypeError: Cannot read property 'match' of undefined" error. The javascript and php code is below, is I output the php json to the console and paste it into this -> <a href="http://jsbin.com/uqawig/441/embed?javascript,live" rel="noreferrer">enter link description here</a> it works! But it doesn't in my code (which I've pretty well copied from the usage example and jsbin)</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.0/morris.js"&gt;&lt;/script&gt;
      &lt;meta charset=utf-8 /&gt;
      &lt;title&gt;Temperature Monitor&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h3 style="text-align: center"&gt;Temperature Monitor&lt;/h3&gt;
  &lt;div id="tempMonitor"&gt;&lt;/div&gt;
  &lt;script src="aquaponics.charts.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>function getSensorData() {
  
      var dataSet;
      $.ajax({
          type: "POST",
          url: "sensor-data.php",
          data: { waterTemperature: true },
          async: false,
          success: function(data) {
              dataSet = data;
          }
      });
  
      return dataSet;
  }
  
  var dataSet = getSensorData();
  
  var chart = Morris.Line({
      element: 'tempMonitor',
      data: [0, 0],
      xkey: 'datetime',
      ykeys: ['temp_c'],
      labels: ['Series A', 'Series B']
  });
  
  chart.setData(dataSet);
  </code></pre>
  
  <p>PHP (sensor-data.php)</p>
  
  <pre><code>&lt;?php
  require('app-config.php');
  
      $limit = query_limit;
  
      $stmt = $dbh-&gt;prepare('SELECT * FROM sensor_waterTemperature ORDER BY id DESC');
      $stmt-&gt;execute();
  
      echo json_encode($stmt-&gt;fetchAll(PDO::FETCH_ASSOC));
  </code></pre>
  
  <p>JSON OUTPUT (from sensor-data.php)</p>
  
  <pre><code>[{"id":"590","datetime":"2014-07-06 19:05:24","temp_c":"26.25","temp_f":"79.25"},{"id":"589","datetime":"2014-07-06 19:00:14","temp_c":"26.31","temp_f":"79.36"},{"id":"588","datetime":"2014-07-06 18:55:13","temp_c":"26.31","temp_f":"79.36"},{"id":"587","datetime":"2014-07-06 18:50:12","temp_c":"26.31","temp_f":"79.36"},{"id":"586","datetime":"2014-07-06 18:45:11","temp_c":"26.31","temp_f":"79.36"},{"id":"585","datetime":"2014-07-06 18:40:10","temp_c":"26.38","temp_f":"79.48"},{"id":"584","datetime":"2014-07-06 18:35:09","temp_c":"26.38","temp_f":"79.48"},{"id":"583","datetime":"2014-07-06 18:30:08","temp_c":"26.38","temp_f":"79.48"},{"id":"582","datetime":"2014-07-06 18:25:07","temp_c":"26.38","temp_f":"79.48"},{"id":"581","datetime":"2014-07-06 18:20:06","temp_c":"26.38","temp_f":"79.48"},{"id":"580","datetime":"2014-07-06 18:15:05","temp_c":"26.38","temp_f":"79.48"},{"id":"579","datetime":"2014-07-06 17:17:44","temp_c":"26.38","temp_f":"79.48"},{"id":"578","datetime":"2014-07-06 18:07:48","temp_c":"26.38","temp_f":"79.48"}]
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I did some more debugging and found the error is happening on morris.js:598 (see below).</p>
  
  <pre><code>Morris.parseDate = function(date) {
      var isecs, m, msecs, n, o, offsetmins, p, q, r, ret, secs;
      if (typeof date === 'number') {
        return date;
      }
      m = date.match(/^(\d+) Q(\d)$/); **&lt;&lt;&lt; RIGHT HERE**
      n = date.match(/^(\d+)-(\d+)$/);
      o = date.match(/^(\d+)-(\d+)-(\d+)$/);
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  I tried this as well and same error occurs.</p>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>function getSensorData() {
  
      $.ajax({
          type: "POST",
          url: "sensor-data.php",
          data: { waterTemperature: true },
          async: false,
          success: function(data) {
  
              Morris.Line({
                  element: 'tempMonitor',
                  data: data,
                  xkey: 'datetime',
                  ykeys: ['temp_c'],
                  labels: ['Series A', 'Series B']
              });
          }
      });
  }
  
  getSensorData();
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php
  require('app-config.php');
  
      $limit = query_limit;
  
      $stmt = $dbh-&gt;prepare('SELECT * FROM sensor_waterTemperature ORDER BY id DESC');
      $stmt-&gt;execute();
  
      //echo json_encode($stmt-&gt;fetchAll(PDO::FETCH_ASSOC));
      while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
          echo '{ datetime: \''.$row['datetime'].'\', temp_c: '.round($row['temp_c'], 2).' },';
      }
  </code></pre>