1
I’m trying to use D3.js but I’m not getting it. I have the code below, but it doesn’t print the map of Brazil. The screen shows no error, what could it be? my file "meso.json" is in topojSON format but it turns the topojSON into Geojson already in D3.js code:
<html>
<head>
<title>D3.js</title>
<meta charset="utf-8" />
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 900,
height = 650;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var projection = d3.geo.mercator()
.center([55,10])
.scale(750);
var path = d3.geo.path()
.projection(projection);
queue()
.defer(d3.json, "topo/meso.json")
.await(ready);
function ready(error, br_mesos){
if(error) return console.error(error);
var mesos = topojson.feature(br_mesos, br_mesos.objects.meso);
svg.append("path")
.datum(mesos)
.attr('d', path)
.attr('class', 'mesos');
}
</script>
</head>
<body>
</body>
</html>
See if there are any errors in the console. I could not simulate due to
"topo/meso.json"
. You’d help us if you could provide it.– BrTkCa
is a folder called "top" that has this json file.
– Alisson Acioli