Javascript 使用D3.js向后移动节点
这是向后移动节点的功能,因此:Javascript 使用D3.js向后移动节点,javascript,d3.js,Javascript,D3.js,这是向后移动节点的功能,因此: d3.selection.prototype.moveToBack = function() { return this.each(function() { var firstChild = this.parentNode.firstChild; if (firstChild) { this.parentNode.insertBefore(this, firstChild);
d3.selection.prototype.moveToBack = function() {
return this.each(function() {
var firstChild = this.parentNode.firstChild;
if (firstChild) {
this.parentNode.insertBefore(this, firstChild);
}
});
};
如果我这样使用它,它会工作,但是:
node.enter().append("g").moveToBack();
moveToBack
未定义,问题是我应该原型化哪个对象,以使其适用于select(“g”)
?这两个调用都适用于我。你能提供一个现场演示来再现效果吗?我猜node.exit()
包含你已经想要的g
节点,并且上的选择(“g”)
是空的,因为没有嵌套的g
元素。
node.exit().select("g").moveToBack();