Accessing SVG path length in d3
path.each(function(d) { d.totalLength = this.getTotalLength(); })
.attr("stroke-dasharray", function(d) { return d.totalLength + " " + d.totalLength; })
.attr("stroke-dashoffset", function(d) { return d.totalLength; })