Last active
November 17, 2022 17:40
-
-
Save jgphilpott/cf12c05f7c30844a4d7fa70ec9a7945a to your computer and use it in GitHub Desktop.
Functions for sorting SVG elements with D3.
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
# Requirement: https://github.com/d3/d3 | |
# Credit: https://stackoverflow.com/a/42998001/1544937 | |
d3.selection.prototype.setAsFrontLayer = -> | |
return this.each -> | |
this.parentNode.appendChild this | |
d3.selection.prototype.setAsBackLayer = -> | |
return this.each -> | |
firstChild = this.parentNode.firstChild | |
if firstChild | |
this.parentNode.insertBefore this, firstChild |
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
// Generated by CoffeeScript 2.7.0 | |
// Requirement: https://github.com/d3/d3 | |
// Credit: https://stackoverflow.com/a/42998001/1544937 | |
d3.selection.prototype.setAsFrontLayer = function() { | |
return this.each(function() { | |
return this.parentNode.appendChild(this); | |
}); | |
}; | |
d3.selection.prototype.setAsBackLayer = function() { | |
return this.each(function() { | |
var firstChild; | |
firstChild = this.parentNode.firstChild; | |
if (firstChild) { | |
return this.parentNode.insertBefore(this, firstChild); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment