title: Curve d3 line animated using tweendash
body: <p>Hi I am trying to curve the linestring like given in the fiddle <a href="http://jsfiddle.net/nj37gkgq/" rel="nofollow">http://jsfiddle.net/nj37gkgq/</a>. Line is an array of links having source and destination in the form of coordinates. This line is connecting two markers in d3.geo maps. How can I achieve this?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
   &lt;html lang='en'&gt;
  
   &lt;style type="text/css"&gt;
  
  
  
  &lt;body&gt;
  
  
  &lt;script src="//d3js.org/d3.v3.min.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script src="//d3js.org/topojson.v1.min.js"&gt;&lt;/script&gt;
  
  &lt;div id="map"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  
      var width = 650,
      height = 600;
  
  var projection = d3.geo.albersUsa()
      .scale(2500)
      .translate([1000, 360]);
  
  
  var path = d3.geo.path()
      .projection(projection);
  
  var svg = d3.select("#map").append("svg")
      .attr("width", width)
      .attr("height", height);
  
  var coordinates = [
    [ -122.762, 40.801 ],
    [ -117.0978, 34.1178]
  ];
  
  
  d3.json(url, function(ca) {
  
          svg.append("path")
              .datum(topojson.mesh(ca, ca.objects.subunits, function(a, b) { return a === b;}))
              .attr("d", path);
  
          //for stroke of lines
          var gradient = svg.append("svg:defs")
              .append("svg:linearGradient")
              .attr("id", "gradient")
              .attr("x1", "0%")
              .attr("y1", "0%")
              .attr("x2", "100%")
              .attr("y2", "100%")
              .attr("spreadMethod", "pad");
  
          gradient.append("svg:stop")
              .attr("offset", "0%")
              .attr("stop-color","darkblue")
              .attr("stop-opacity", 1);
  
          gradient.append("svg:stop")
              .attr("offset", "100%")
              .attr("stop-color","#85c1e9")
              .attr("stop-opacity", 1);
  
           var lF = d3.svg.line()
                        .interpolate("basis")
                        .x(function(d){ return d[0] })
                        .y(function(d){ return d[1] });
  
          //update
          var line = svg.append("path")
              .datum(coordinates)
              .attr("d", function(c){
  
                  var d = {
                      source: projection(c[0]),
                      target: projection(c[1])
                  },
  
                    points = [];
  
                    points.push(d.source);
                    points.push([(d.target[0] + d.source[0]) * .4, d.target[1]]);
                    points.push([(d.target[0] + d.source[0]) * .8, d.source[1]]);
                    points.push(d.target);
                    console.log(points);
  
                    return lF(points);
              })
              .attr("stroke-width", "2.5")
              .attr("stroke-linejoin", "round")
              .attr("stroke-linecap", "round")
              .style("stroke", "url(#gradient)");
  
          anim();
  
          function anim() {
              line.transition()
                  .duration(2000)
                  .attrTween("stroke-dasharray", function() {
                      var len = this.getTotalLength();
                      return function(t) {
                        return (d3.interpolateString("0," + len, len + ",0"))(t)
                      };
                  })
                .each('end', anim);
          }
  
  });
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>