I am trying to read a .json file into an HTML file using d3.
When I use one .json file -- for the entire US -- the map shows up fine. However, when I tried switching out the US file for a state of Wisconsin .json file it shows up like this...
Anyone know what the issue could be?
Here's the code:
<script>
var margin = {top: 20, left: 20, bottom: 20, right: 20}
height = 600-margin.top - margin.bottom,
width = 960 - margin.left - margin.right;
var svg2 = d3.select("#map2").append("svg")
.attr("height", height)
.attr("width", width)
.append("g")
.attr("transform", "translate(" + margin.left + "," +
margin.right + ")");
d3.queue()
.defer(d3.json, "wiscCountiesGeneralized.json")
.await(ready);
var projection2 = d3.geoAlbers()
.translate([width/2, height/1.5])
.scale(75)
var path2 = d3.geoPath()
.projection(projection2)
function ready (error, data) {
console.log(data)
var counties = topojson.feature(data,
data.objects.counties).features
console.log(counties)
svg2.selectAll(".counties")
.data(counties)
.enter().append("path")
.attr("class", "counties")
.attr("d", path2)
}
</script>