simple transition demo
Last active
January 3, 2016 18:16
-
-
Save pbogden/7031977 to your computer and use it in GitHub Desktop.
transition demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<title>Transition</title> | |
<style> | |
.label { | |
fill: #444; | |
font: sans-serif; | |
font-size: 30px; | |
font-weight: 300; | |
text-anchor: middle; | |
} | |
</style> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script> | |
<body> | |
<script> | |
var width = 960, | |
height = 500; | |
// Eliminate default margin from <body> element | |
document.body.style.margin="0px"; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + "px") | |
.attr("height", height + "px"); | |
svg.append("circle") | |
.style("fill", "red") | |
.attr("cx", 200) | |
.attr("cy", 200) | |
.attr("r", 100) | |
.transition() // Start transition to medium black | |
.duration(1000) | |
.ease("linear") | |
.attr("r", 50) | |
.style("fill", "black") | |
.transition() // Start transition to nothing | |
.duration(1000) | |
.attr("r", 0); | |
svg.append("text") | |
.attr("class", "label") | |
.attr("transform", "translate(300,300)") | |
.text("start") | |
.transition() | |
.delay(1000) | |
.text("done"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment