Skip to content

Instantly share code, notes, and snippets.

@git-ashish
Forked from joews/d3-bring-to-front.js
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save git-ashish/073f58a96a04dd947bee to your computer and use it in GitHub Desktop.
Save git-ashish/073f58a96a04dd947bee to your computer and use it in GitHub Desktop.
// Credit Christopher Chiche & Clemens Tolboom
// - http://stackoverflow.com/a/14426477/2806996
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);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment