Skip to content

Instantly share code, notes, and snippets.

@dheerosaur
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save dheerosaur/5506ec8c7aa48a1e8717 to your computer and use it in GitHub Desktop.

Select an option

Save dheerosaur/5506ec8c7aa48a1e8717 to your computer and use it in GitHub Desktop.
var transform, d3path;
function initSVG() {
transform = d3.geo.transform({ point: projectPoint });
d3path = d3.geo.path().projection(transform);
}
// We do the following for each feature
feature.geometry.coordinates = polyline.decode(
feature.geometry.coordinates);
// This g is an SVG group element to hold all paths
g.append('path')
.attr('d', d3path(feature))
.datum(feature.properties)
.each(pathTransition);
function pathTransition (d) {
var duration = d.duration * 1000 / ( 60 * timeFactor);
d3.select(this)
.attr('class', d.terminal)
.transition()
.duration(duration)
.each('start', function (d) {
this.style.opacity = 1;
})
.each('end', function (d) {
updateCounts(d.terminal);
// Fade out destination marker
marker.attr('class', d.terminal)
.transition()
.duration(3000)
.style('opacity', 0)
.remove();
// Fade out line
d3.select(this)
.transition()
.duration(500)
.style('opacity', 0)
.remove();
})
.attrTween('stroke-dasharray', function () {
return d3.interpolateString('0,' + l, l + ',' + l);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment