我有兴趣用dcJs可视化Meteor数据(mongoDb)。但是,我无法找到有关此主题的更多信息。
我使用Meteor重新创建了http://www.codeproject.com/Articles/697043/Making-Dashboards-with-Dc-js-Part-2-Graphing。
不要打电话给mongodb,
var data = [
{_id: "iD1", date: "12/27/2012", http_404: 2, http_200: 190, http_302: 100},
{_id: "iD2", date: "12/28/2012", http_404: 2, http_200: 10, http_302: 100},
{_id: "iD3", date: "12/29/2012", http_404: 1, http_200: 300, http_302: 200},
{_id: "iD4", date: "12/30/2012", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD5", date: "12/31/2012", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD6", date: "01/01/2013", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD7", date: "01/02/2013", http_404: 1, http_200: 10, http_302: 1},
{_id: "iD8", date: "01/03/2013", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD9", date: "01/04/2013", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD10", date: "01/05/2013", http_404: 2, http_200: 90, http_302: 0},
{_id: "iD11", date: "01/06/2013", http_404: 2, http_200: 200, http_302: 1},
{_id: "iD12", date: "01/07/2013", http_404: 1, http_200: 200, http_302: 100}
];
结果很好。
通过插入和调用mongodb中的数据,失败。
不确定这里缺少什么。
希望得到建议。谢谢!
答案 0 :(得分:1)
我怀疑以下代码触发了错误:
var minDate = dateDim.bottom(1)[0].date;
var maxDate = dateDim.top(1)[0].date;
在从数据库加载数据之前,可能会触发模板渲染回调。
修复它的最简单方法可能是放一个if语句:
if (Dichas.find().count() !== 0) {
... all of the code that depends on there being data
}