title: Loading JSON into C3.js using javascript express routes
body: <p>I am trying to draw a graph using c3.js. I was able to follow the getting started so I know the module is working correctly, but I am having troubles with the graph not displaying when I try to use my own data.</p>
  
  <p>I am taking data from a database and storing it like so:</p>
  
  <pre><code>MongoClient.connect(url, function(err, db) {
    assert.equal(null, err);
    console.log("Connected successfully to server");
    findDocuments(db, function(docs){
        //console.log(docs);
        exports.getData = function(){
          return docs;
        }
      db.close();
    });
  });
  </code></pre>
  
  <p>I know for certain this works, it provides the following output in a long string:</p>
  
  <pre><code>[{"_id":"5885dc66c2ef160d2163fb79",
   "temperature":18,
   "humidity":27,
   "visibleLight":260,
   "irLight":255,
   "date":"2017-01-23T10:35:16+00:00",
   "epochtime":1485167716703}]
  </code></pre>
  
  <p>This data is then loaded into my view using index.js like so:</p>
  
  <pre><code>router.get('/', function (req, res) {
    res.render('index', { 
      title: 'Dashboard', 
      allData: db.getData()
    });
  })
  </code></pre>
  
  <p>According to these samples here: <a href="http://c3js.org/samples/data_json.html" rel="nofollow noreferrer">http://c3js.org/samples/data_json.html</a>
  I attempt to draw the graph:</p>
  
  <pre><code>var chart = c3.generate({
    data: {
      json: allData,
      keys: {
        x: 'date', // it's possible to specify 'x' when category axis
        value: ['temperature', 'humidity'],
      }
    },
    axis: {
      x: {
        type: 'timeseries'
      }
    }
  });
  </code></pre>