Queue error “Uncaught TypeError: Cannot read property 'objects' of null”

こ雲淡風輕ζ 提交于 2019-12-24 11:25:06

问题


I'm trying to using queues to ensure my files are loaded fully before the script continues. However, when I load in my json map files and try to use them in a function, I get an error.

var counties = svg.append("g")
    .attr("id", "counties")
    .attr("class", "Blues");

var states = svg.append("g")
    .attr("id", "states");

    queue()
    .defer(d3.json, "county.json")
    .defer(d3.json, "state.json")
    .defer(d3.json, "Crashes.json")
    .await(ready);

function ready(county, state, crashes) {
    var countyFeatures = topojson.feature(county, county.objects.counties);
    var stateFeatures = topojson.feature(state, state.objects.states);

    /*
    counties.selectAll("path")
        .data(county.features)
      .enter().append("path")
        .attr("class", "q8-9")
        .attr("d", path);

    states.selectAll("path")
        .data(state.features)
      .enter().append("path")
        .attr("d", path);   
      */
}

The error is Uncaught TypeError: Cannot read property 'objects' of null

Can someone explain why when passing into the function it is null? As opposed to running d3.json separately and using

d3.json("URL", function(d) {var temp = topojson.feature(d, d.objects.counties;});

Thanks.

来源:https://stackoverflow.com/questions/22247330/queue-error-uncaught-typeerror-cannot-read-property-objects-of-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!