我在下面的代码块上抛出错误“无法读取未定义”的属性'对象'。这是否意味着us.json文件未加载?我使用控制台日志对其进行了测试,它确实显示正确加载,并且 属于objects
属性,那么出了什么问题?
queue()
// Load map JSON
.defer(d3.json,
'https://rawgit.com/HyperrealTech/thorn-directives/master/lib/us.json')
// Load applicable data
.defer(d3.json, data)
// Call rateById for each d in data
.await(function(d) {
rateById.set(d.state, +d.count);
})
// Once finished loading, call ready function
.await(ready);
// Ready function
function ready(error, us) {
// Sum values in data to arrive at total
var total = 0;
for(var value in rateById) {
if(rateById.hasOwnProperty(value)) {
total += parseInt(rateById[value], 10);
}
}
// Append states to svg
svg.append('g')
.attr('class', 'states')
.selectAll('path')
// Error here
.data(topojson.feature(us, us.objects.states).features)