1
我想在SVG
圈内追加文字 this例如在我的D3
地图中。我见过很多类似的问题 - 我已经用它们来编写下面的代码,但不明白为什么它根本不显示。D3中的SVG圈内文字不显示
d3.json("https://raw.githubusercontent.com/d3/d3.github.com/master/world-110m.v1.json", function (error, topo) {
if (error) throw error;
gBackground.append("g")
.attr("id", "country")
.selectAll("path")
.data(topojson.feature(topo, topo.objects.countries).features)
.enter().append("path")
.attr("d", path);
gBackground.append("path")
.datum(topojson.mesh(topo, topo.objects.countries, function (a, b) { return a !== b; }))
.attr("id", "country-borders")
.attr("d", path);
console.log("Background Drawn");
var point = gPoints.selectAll("circle")
.data(pointsData)
.enter()
.append("circle")
.attr("cx", function (d) { return d.location[0]; })
.attr("cy", function (d) { return d.location[1]; })
.attr("r", 10)
//Other attributes and mouseovers, etc
var texts = gPoints.selectAll("text")
.data(pointsData)
.enter()
.append("text")
.text(function (d) { return d.performance; });
console.log("Points Drawn");
});
由于里面的文字! (它的作品,但不是与缩放功能) – Sbee