Skip to content

Instantly share code, notes, and snippets.

@jonsadka
Last active September 18, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsadka/4edd58e2bd5b66733d4a to your computer and use it in GitHub Desktop.
Save jonsadka/4edd58e2bd5b66733d4a to your computer and use it in GitHub Desktop.
Playing with d3.timer()
license: mit

Playing with d3.timer().

<!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