Created
August 16, 2013 23:38
-
-
Save ghernandez345/6254427 to your computer and use it in GitHub Desktop.
d3 animated path rendering
This file contains hidden or 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
// This will animate all the path rendering to draw from the begining of the path to the end of the path | |
var paths = d3.selectAll('path.link'); | |
paths.each(function () { | |
var path = d3.select(this); | |
var totalLength = path.node().getTotalLength(); | |
path.attr("stroke-dasharray", totalLength + " " + totalLength) | |
.attr("stroke-dashoffset", totalLength) | |
.transition() | |
.ease('linear') | |
.duration(300) | |
.ease("linear") | |
.attr("stroke-dashoffset", 0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment