Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Created July 20, 2012 07:50
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 morenoh149/3149367 to your computer and use it in GitHub Desktop.
Save morenoh149/3149367 to your computer and use it in GitHub Desktop.
transition d3js tutorial
<meta charset="utf-8">
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<button class="btn btn-mini" id="button">Transition</button>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 500)
.attr("height", 300);
var mySquare=svg.append("rect")
.attr("x",60)
.attr("y",60)
.attr("width",60)
.attr("height",60);
mySquare
.style("fill","blue");
var button = d3.select("#button");
button.on("click", function(){
mySquare.transition().style("fill","white");
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment