में मानचित्र में राज्यों के नाम जोड़ें I मानचित्र प्रदर्शित करने के लिए albersUSA प्रक्षेपण का उपयोग कर रहा हूं। मैं प्रत्येक राज्य में राज्यों का नाम जोड़ना चाहता हूं।d3.js
यही मैंने कोशिश की है, और मैं स्रोत में राज्यों के नाम देख सकता हूं, लेकिन मुझे उन्हें प्रस्तुत नहीं किया जाता है। मैं क्या गलत कर रहा हूँ?
var width = 1060,
height = 600,
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("rect")
.attr("class", "background")
.attr("width", width)
.attr("height", height)
.on("click", click)
.on("mousemove", mousemove);
var g = svg.append("g")
.attr("transform", "translate(" + width/2 + "," + height/2 + ")")
.append("g")
.attr("id", "states");
var projection = d3.geo.albersUsa()
.scale(width)
.translate([0, 100]);
var path = d3.geo.path()
.projection(projection);
draw();
function draw(){
d3.json("readme.json", function(json) {
g.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.append("svg:text")
.text(function(d){
return d.properties.name;
})
.attr("x", function(d){
return -path.centroid(d)[0];
})
.attr("y", function(d){
return -path.centroid(d)[1];
});
});
}
आप '-path.centroid (डी) [0] क्यों लौट रहे हैं; ', यह' path.centroid (डी) [0] होना चाहिए; '? – Duopixel