D3.js, force-graph, cannot display text/label of nodes

后端 未结 1 1793
悲哀的现实
悲哀的现实 2020-12-20 14:50

I cannot display labels of nodes using a force-layout in d3.js.

I\'m trying with this example http://d3js.org/d3.v3.min.js

I updated that code only adding zo

相关标签:
1条回答
  • 2020-12-20 15:20

    You need to separately add the text:

    node.append("text")
        .attr("dx", ".10em")
        .attr("dy", ".10em")
        .text(function(d) { return d.name; });
    

    see these examples:

    http://bl.ocks.org/mbostock/2706022

    http://bl.ocks.org/mbostock/1153292

    0 讨论(0)
提交回复
热议问题