我已经创建了一些具有某些值的文本节点。因此,每当数据更新时,只有该值应该更新,文本节点不应再次创建。
systemLevel
.enter()
.append('g')
.classed("system-level", true)
.attr("depth", function(d, i) {
return i;
})
.each(function(d, i) {
var columnHeader = graphHeaders.append("g")
.classed("system-column-header", true);
columnHeader.append('text')
.attr('font-size', '14')
.attr('font-weight', 'bold')
.attr('fill', "red")
.attr('x', 50 * i)
.attr('y', 50)
.text(function() {
return d.newUser;
});
columnHeader.append('text')
.attr('font-size', '14')
.attr('font-weight', 'bold')
.attr('fill', "blue")
.attr('x', 50* i)
.attr('y', 70)
.text(function() {
return d.value;
});
});
我已经在Js Bin上创建了一个示例。 https://jsbin.com/dixeqe/edit?js,output 我不确定如何仅更新文本值。希望得到帮助!