[ Launch: Circles Tutorial ] 8fb1e3c297ef5515d8ee by jkeohan
[ Launch: EUE - Circles ] 50266c8589dea75305e0 by jkeohan
[ Launch: Tributary inlet ] e6f770d6f51707fccb9d by jkeohan
-
-
Save jkeohan/8fb1e3c297ef5515d8ee to your computer and use it in GitHub Desktop.
Circles Tutorial
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":"Circles Tutorial","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/wvqpXTB.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 data = [1,2,3] | |
| var svg = d3.select('svg') | |
| var circles = svg.selectAll("circle").data(data.sort(d3.descending)) | |
| 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(50)) | |
| .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([1,2,3]) | |
| .enter().append("circle") | |
| .attr("r", 0) | |
| .attr("cx", 0) | |
| .attr("cy", y) | |
| //.style("fill", function(d) { return z(Math.abs(d % 20 - 10)); }) | |
| .style("fill","blue") | |
| .transition() | |
| .duration(2500) | |
| .delay(function(d) { return d * 40; }) | |
| .each(slide); | |
| function slide() { | |
| var circle = d3.select(this); | |
| (function repeat() { | |
| circle = circle.transition() | |
| .attr('r',10) | |
| //.attr("cx", 300) | |
| .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