Created
February 29, 2016 10:33
-
-
Save KeithNdhlovu/86aac4b9de7d1eada175 to your computer and use it in GitHub Desktop.
Moove objects Above other objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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