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人。
这些错误意味着什么?
答案 0 :(得分:3)
尝试
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"]);