Why does D3 not update the text

前端 未结 1 477
猫巷女王i
猫巷女王i 2021-01-27 11:06

I\'m trying to create a tree using D3 and am having trouble changing the text of my nodes after changing dataset. My code for updating/creating the tree is pasted below:

1条回答
  •  执笔经年
    2021-01-27 12:00

    You are not updating the text in the update selection. To do that, use something like the following code:

    nodeUpdate.select("text")
      .text(function(d) { console.log(d.name); return d.name; })
      .style("fill-opacity", 1);
    

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