Skip to content

Instantly share code, notes, and snippets.

@nsonnad
Created March 10, 2013 05: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 nsonnad/5127223 to your computer and use it in GitHub Desktop.
Save nsonnad/5127223 to your computer and use it in GitHub Desktop.
basic data re-join in d3
{"description":"basic data re-join in d3","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"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}
var svg = d3.select('svg')
.attr('width', 300)
.attr('height', 300);
var group = svg.append('g');
function redraw(data) {
var circle = group.selectAll('circle')
.data(data)
.enter().append('circle')
.attr('r', function (d) { return d; })
.attr('fill', 'orange')
.attr('transform', 'translate(150,150)');
d3.transition().select('circle')
.ease('bounce').duration(400)
.attr('r', function (d) { return d; });
}
setInterval(function() {
var random = Math.floor(Math.random() * 150);
redraw([random]);
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment