Skip to content

Instantly share code, notes, and snippets.

@alatzl
Last active August 29, 2015 14:23
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 alatzl/c6a6d74703906368d8df to your computer and use it in GitHub Desktop.
Save alatzl/c6a6d74703906368d8df to your computer and use it in GitHub Desktop.
Three Circles Setup
{"description":"Three Circles Setup","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/DFgDX32.png","ajax-caching":true}
var svg = d3.select("svg");
var data = [ 42, 13, 69 ];
//make groups for each data point. put a circle in each group. add labels to each circle.
var groups = svg.selectAll('g')
.data(data)
.enter()
.append('g')
.attr('transform', function(d, i) {
var x = 50 + i*100;
var y = 50 + i*100;
return "translate(" + [x,y] + ")";
});
var circles = groups.append('circle')
.attr({
'cx': 0,
'cy': 0,
'r': 25,
'fill': '#999',
'stroke': '#111',
'stroke-width': 2
});
var labels = groups.append('text')
.text(function(d, i) {
return d;
})
.attr({
'text-anchor': 'middle',
'alignment-baseline': 'middle'
});
circles.exit().remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment