Skip to content

Instantly share code, notes, and snippets.

@jamesongamble
Created October 8, 2014 20:16
Show Gist options
  • Save jamesongamble/54e2568b6d9d6f55ab8d to your computer and use it in GitHub Desktop.
Save jamesongamble/54e2568b6d9d6f55ab8d to your computer and use it in GitHub Desktop.
// start slingin' some d3 here.
var update = function(data) {
var board = d3.select("body").select("svg").selectAll("image.pira")
.data(data)
board.enter().append("image")
.attr("height", function() {
return "50";
})
.attr("width", function() {
return "50";
})
.attr("class", "pira")
.attr("xlink:href", function() {
return "pira.png";
})
//transition
.transition()
.duration(1000)
.attr("x", function(d) {
return d[0];
})
.attr("y", function(d) {
return d[1];
});
board.attr("height", function() {
return "50";
})
.attr("width", function() {
return "50";
})
.attr("class", "pira")
.attr("xlink:href", function() {
return "pira.png";
})
.transition()
.duration(1000)
.attr("x", function(d) {
return d[0];
})
.attr("y", function(d) {
return d[1];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment