javascript - How to add text to paths -


i suspect i'm barking wrong tree - although i've got no errors in console me out.

i've got block of code:

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 "foo" not appear path.append("text")     .text(function(d) {         return "foo";     })     .style("stroke", "#3b5998")     .style("fill", "#3b5998"); 

the code snippet beginning path.append("title")... works ok final snippet beginning path.append("text")... adds text foo html not visible on webpage - why not visible , how add labels?

this part of visual:

http://plnkr.co/edit/q9odd5?p=preview

text cannot nested path. you'll need add svg instead. additionally, you'll want position text in way:

  svg.append("text")     .text(function(d) {         return "foo";     })     .attr("x", function(){ return 0 })     .attr("y", function(){ return 0 })     .style("stroke", "#3b5998")     .style("fill", "#3b5998"); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -