Skip to content

Instantly share code, notes, and snippets.

@latentflip
Created April 1, 2013 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save latentflip/5285027 to your computer and use it in GitHub Desktop.
Save latentflip/5285027 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
svg circle {
fill: #D0002A;
}
</style>
</head>
<body>
<svg></svg>
<script>
var data = [];
var svg = d3.select("svg")
setInterval(addCircle, 500)
function addCircle() {
data.push({x: Math.random()*600, y: Math.random()*400 })
var circles = svg.selectAll('circle')
.data(data)
circles.enter().append('circle')
.attr('cx', function(d) { return d.x })
.attr('cy', function(d) { return d.y })
.attr('r', 0)
.transition().duration(500)
.attr('r', 5)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment