D3.js binds to an attribute value update of the data on an element, and how to update the corresponding value of its child elements

  var node = this.vis.selectAll(".node").data(nodes, function(d) {
                    return d.id;
                });

  var svg = node.enter().append("svg:svg").classed("node",true);
        svg.append("svg:image").attr("href",function(d){return d.src});
        
< hr >

as above, when you click Refresh, the nodes data has been updated, but the data obtained by d on img is still the data previously bound, not the latest data

Mar.23,2021

enter is only applicable to newly added elements. If you want to have an existing element update, you can use the following methods

node.select('svg:image').attr('href', function(d) { return d.src });

about D3.js Update, Enter and Exit, please take a look at this article http://wiki.jikexueyuan.com/p.

.
Menu