var tasks;
d3.json("http://localhost:8080/result", function(error, data) {
tasks = data
data.forEach(function(d) {
d.startDate = new Date(d.maxTime["$date"]);
d.endDate = new Date(d.minTime["$date"]);
});
var taskNames = ["Bob", "Sam"];
var gantt = d3.gantt().taskTypes(taskNames);
gantt(data);
});
我正在使用here的帮助
这是我从http://localhost:8080/result返回的
json
对象数组:[
{"minTime": {"$date": 1459555200000},
"maxTime": {"$date": 1459555860000},
"Time": 660.0, "Name": "Sam"},
{"minTime": {"$date": 1459558800000},
"maxTime": {"$date": 1459563265000},
"Time": 4465.0, "Name": "Bob"},
{"minTime": {"$date": 1459562400000},
"maxTime": {"$date": 1459563842000},
"Time": 1442.0, "Name": "Sam"},
...
]
我收到一个错误
负值无效。 (“ -30.00296 864734321”)
和其他397个。
这些错误是什么意思?
最佳答案
尝试
d.startDate = new Date(d.maxTime.$date);
d.endDate = new Date(d.minTime.$date);
要么
d.startDate = new Date(d.maxTime["$date"]);
d.endDate = new Date(d.minTime["$date"]);
关于javascript - d3.js甘特图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37526981/