Skip to content

Instantly share code, notes, and snippets.

@KeithNdhlovu
Created February 29, 2016 10:33
Show Gist options
  • Save KeithNdhlovu/86aac4b9de7d1eada175 to your computer and use it in GitHub Desktop.
Save KeithNdhlovu/86aac4b9de7d1eada175 to your computer and use it in GitHub Desktop.
Moove objects Above other objects
d3.selection.prototype.moveToFront = function() {
return this.each(function(){
this.parentNode.appendChild(this);
});
};
d3.selection.prototype.moveToBack = function() {
return this.each(function() {
var firstChild = this.parentNode.firstChild;
if (firstChild) {
this.parentNode.insertBefore(this, firstChild);
}
});
};
// Usage example
circles.on("mouseover",function(){
var sel = d3.select(this);
sel.moveToFront();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment