Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created August 7, 2013 11:04
Show Gist options
  • Save ynonp/6173118 to your computer and use it in GitHub Desktop.
Save ynonp/6173118 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<svg id="container"></svg>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js"></script>
<script>
var data = [10, 20, 5, 8, 15];
var visualize = function(selection) {
selection
.attr('cx', function(d, i) {
return i * 80 + 50;
})
.attr('cy', 50)
.attr('r', function(d, i) {
return d * 2;
});
};
var svg = d3.select('svg');
var selection = svg.selectAll('circle').data( data );
selection.enter().append('circle');
selection.exit().remove();
selection.call( visualize );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment