Skip to content

Instantly share code, notes, and snippets.

@mundhradevang
Created August 20, 2011 07:32
Show Gist options
  • Save mundhradevang/1158805 to your computer and use it in GitHub Desktop.
Save mundhradevang/1158805 to your computer and use it in GitHub Desktop.
Transition breaking on each?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<script type="text/javascript" src="trans.js"></script>
</body>
</html>
var w = 960,
h = 500;
var svg = d3.select("body").append("svg:svg")
.style("width", w)
.style("height", h)
.append("svg:rect")
.attr("width", w)
.attr("height", h)
.style("fill", "blue")
.on("click", onClick);
function onClick(d,i) {
d3.select(this)
.transition()
.each(changeToBlack);
}
function changeToBlack(d,i) {
d3.select(this)
.style("fill", "black");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment