Reputation: 4370
I am using force layout and i have some problem in displaying text in the layout. Here is the screenshot :
and my code is :
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 is there in the code, but its not showing in the browser. I even changed the color but nothing helps.
Upvotes: 1
Views: 44
Reputation: 1423
As @Lars Kotthoff mentioned circle
s don't support text()
. you should change your code to sample like 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.
Upvotes: 1