[ Launch: Tributary inlet ] 90ebe2fad53a98a6272d by jkeohan
-
-
Save jkeohan/90ebe2fad53a98a6272d to your computer and use it in GitHub Desktop.
Transition(MB) - .Each()
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
| {"description":"Transition(MB) - .Each()","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/Lu1r1bC.png"} |
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
| var margin = {top: 40, right: 40, bottom: 40, left: 40}, | |
| width = 960 - margin.left - margin.right, | |
| height = 500 - margin.top - margin.bottom; | |
| var y = d3.scale.ordinal() | |
| .domain(d3.range(5)) | |
| .rangePoints([0, height]); | |
| var z = d3.scale.linear() | |
| .domain([10, 0]) | |
| .range(["hsl(62,100%,90%)", "hsl(228,30%,20%)"]) | |
| .interpolate(d3.interpolateHcl); | |
| var svg = d3.select("svg") | |
| .attr("width", width + margin.left + margin.right) | |
| .attr("height", height + margin.top + margin.bottom) | |
| .append("g") | |
| .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
| svg.selectAll("circle") | |
| .data(y.domain()) | |
| .enter().append("circle") | |
| .attr("r", 10) | |
| .attr("cx", 100) | |
| .attr("cy", y) | |
| .style("fill", function(d) { return z(Math.abs(d % 20 - 10)); }) | |
| .transition() | |
| .duration(2500) | |
| .delay(function(d,i) { return d }) | |
| .each(slide); | |
| function slide() { | |
| var circle = d3.select(this); | |
| (function repeat() { | |
| circle = circle.transition() | |
| .attr("cx",50) | |
| .transition() | |
| .attr("cx", 0) | |
| .each("end", repeat); | |
| })(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment