[ Launch: chained transition ] 5506357 by enjalot
-
-
Save enjalot/5506357 to your computer and use it in GitHub Desktop.
chained transition
This file contains 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":"chained transition","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":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/avyUBjG.png"} |
This file contains 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 = [10, 20, 30]; | |
var svg = d3.select("svg") | |
var circles = svg.selectAll("circle") | |
.data(data) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: function(d,i) { return 100 + i * 82 }, | |
cy: 100, | |
r: function(d) { return d } | |
}) | |
var button = svg.append("rect") | |
.attr({ | |
x: 130, | |
y: 160, | |
width: 100, | |
height: 20 | |
}) | |
.on("click", function() { | |
//"new data" | |
data = [20, 30, 40]; | |
svg.selectAll("circle") | |
.data(data) | |
.transition() | |
.duration(1500) | |
.attr("r", function(d) { return d }) | |
.style("fill", "#ffffff") | |
.transition() | |
.style("fill", "#000000") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment