Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2016 01:41
What would you like to do?
Update-Only Transition
license: gpl-3.0

Demonstrating how to apply a transition to only updating nodes, and not entering nodes.

<!DOCTYPE html>
<meta charset="utf-8">
<script src="//"></script>
var width = 960,
height = 500;
var x = d3.scale.ordinal()
.domain([0, 1, 2])
.rangePoints([0, width], 1);
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
var circle = svg.selectAll("circle")
.data([0, 1])
.attr("r", height / 4)
.attr("cx", x)
.attr("cy", height / 2);
setTimeout(function() {
circle =[1, 2], function(d) { return d; });
// Since this is created before enter.append, it only applies to updating nodes.
.attr("r", height / 3)
.style("fill", "orange");
.attr("r", height / 4)
.attr("cx", x)
.attr("cy", height / 2)
.style("fill", "green");
.style("fill", "red")
.attr("r", 1e-6)
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment