Playing with d3.timer().
Last active
September 18, 2016 17:14
-
-
Save jonsadka/4edd58e2bd5b66733d4a to your computer and use it in GitHub Desktop.
Playing with d3.timer()
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
license: mit |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="https://d3js.org/d3.v3.min.js"></script> | |
<script> | |
var width = window.innerWidth || 960, | |
height = window.innerHeight || 500; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.timer(function() { | |
for (var i = 0; i < 2; i++) { | |
svg.append("circle") | |
.attr("cx", function(){ | |
return Math.random()*width; | |
}) | |
.attr("cy", function(){ | |
return Math.random()*height; | |
}) | |
.attr("r", 0) | |
.transition() | |
.attr("r", 3); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment