私は間違ったツリーを吠えていると思うが、コンソールでエラーが表示されない。パスにテキストを追加するには
私はこのコードのブロックを持っている:path.append("title")...
を開始
var path = svg.data([json]).selectAll("path")
.data(partition.nodes)
.enter()
.append("path")
.attr("display", function(d) {
return d.depth ? null : "none";
})
.attr("d", arc)
.style("stroke", "#fff")
.style("fill", function(d) {
return color((d.children ? d : d.parent).name);
})
.attr("fill-rule", "evenodd")
.style("opacity", 1)
.each(stash);
//>>this section functions ok
path.append("title")
.text(function(d) {
return d.name + ": " + d.amount;
});
//>>this section throws no errors but "foo" does not appear
path.append("text")
.text(function(d) {
return "foo";
})
.style("stroke", "#3b5998")
.style("fill", "#3b5998");
コードスニペットは、[OK]を動作しますが、path.append("text")...
を始め、最終的なスニペットは、HTMLにテキストFOOを追加しますが、それはWebページに表示されていない - なぜ表示されないのですか?ラベルを追加するにはどうすればよいですか?
これは、視覚の一部です:
http://plnkr.co/edit/q9ODd5?p=preview
[* "D3.jsでのアークのテキストの配置" *(http://www.visualcinnamon.com/2015/09/placing-text-on-arcs.html)を参照してください。それは時間の価値がある! – altocumulus
@altocumulus素晴らしいリンク - ありがとう....見て! http://run.plnkr.co/plunks/V4Zr16/ – whytheq