[ Launch: Tributary inlet ] 5939835 by gelicia
-
-
Save gelicia/5939835 to your computer and use it in GitHub Desktop.
mbostock chained transitions
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":"mbostock chained transitions","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"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":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
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
// copied from http://bl.ocks.org/mbostock/1125997 | |
// this seems very useful! | |
var margin = {top: 40, right: 40, bottom: 40, left: 40}, | |
width = 500 - 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(y.domain()) | |
.enter().append("circle") | |
.attr("r", 25) | |
.attr("cx", 0) | |
.attr("cy", y) | |
.style("fill", function(d) { return z(Math.abs(d % 20 - 10)); }) | |
.transition() | |
.duration(2500) | |
.delay(function(d) { return d * 40; }) | |
.each(slide); | |
function slide() { | |
var circle = d3.select(this); | |
(function repeat() { | |
circle = circle.transition() | |
.attr("cx", width) | |
.transition() | |
.attr("cx", 0) | |
.each("start", repeat); | |
})(); | |
} |
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
circle { | |
fill: #000; | |
stroke: #000; | |
stroke-width: 1.5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment