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
| function updateWindow(){ | |
| x = w.innerWidth || e.clientWidth || g.clientWidth; | |
| y = w.innerHeight|| e.clientHeight|| g.clientHeight; | |
| svg.attr("width", x).attr("height", y); | |
| } | |
| window.onresize = updateWindow; |
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
| //SHADOW | |
| // filter chain comes from: | |
| // https://github.com/wbzyl/d3-notes/blob/master/hello-drop-shadow.html | |
| // cpbotha added explanatory comments | |
| // read more about SVG filter effects here: http://www.w3.org/TR/SVG/filters.html | |
| // filters go in defs element | |
| var defs = svg.append("defs"); | |
| // create filter with id #drop-shadow |
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
| function getDistance(p1, p2) { | |
| return Math.sqrt(squared(p1.x-p2.x) + squared(p1.y-p2.y)); | |
| } | |
| function squared(x){ | |
| return x*x; | |
| } |
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
| //define globally | |
| d3.selection.prototype.moveToFront = function() { | |
| return this.each(function(){ | |
| this.parentNode.appendChild(this); | |
| }); | |
| }; | |
| //set locally in respective elements | |
| var sel = d3.select(this); |
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
| python -m SimpleHTTPServer 8888 |
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
| /* finds the intersection of | |
| * two arrays in a simple fashion. | |
| * | |
| * PARAMS | |
| * a - first array, must already be sorted | |
| * b - second array, must already be sorted | |
| * | |
| * NOTES | |
| * | |
| * Should have O(n) operations, where n is |
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
| //find = this has to be replaced... | |
| //replace = with that str | |
| //str = in this str, please | |
| function replaceAll(find, replace, str) { | |
| return str.replace(new RegExp(find, 'g'), replace); | |
| } |