javascript - Difficulty in displaying text in Force layout ? (D3js) -
i using force layout , have problem in displaying text in layout. here screenshot :
and code :
svg.selectall("circle") .data(data) .enter().append("circle") .attr("class", "node") .attr("fill", "blue") .attr("r", 4.5) .attr("dx", ".10em") .attr("dy", ".10em") .text(function(d){ return d.name});
the text there in code, not showing in browser. changed color nothing helps.
as @lars kotthoff mentioned circle
s don't support text()
. should change code sample this:
svg.selectall("circle") .data(data) .enter().append("circle") .attr("class", "node") .attr("fill", "blue") .attr("r", 4.5) .attr("cx", ".10em") .attr("cy", ".10em"); svg.selectall("text") .data(data) .enter().append("text") .attr("class", "node") .attr("fill", "red") .attr("dx", ".10em") .attr("dy", ".10em") .text(function(d){ return d.name});
jsfiddle code here.
Comments
Post a Comment