Skip to content

Instantly share code, notes, and snippets.

@ds0nt
Last active August 29, 2015 14:20
Show Gist options
  • Save ds0nt/512f5bd0d0eddc571266 to your computer and use it in GitHub Desktop.
Save ds0nt/512f5bd0d0eddc571266 to your computer and use it in GitHub Desktop.
function foo(data) {
console.log(data);
var join = d3.select('div.test').selectAll('span').data(data, function(d, i) { return d.v })
join.exit().remove();
join.enter().append('span').text(function(d) { return d.v } )
join.sort();
}
$(function () {
d3.select('body').append('div').html(layout)
d3.select('div.page').insert('div').attr('class', 'test');
data = [{v:'1'}, {v:'2'}, {v:'3'}, {v:'4'}, {v:'5'}];
foo(data);
setTimeout(function () {
data2 = data.reverse();
foo(data2);
}, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment