toolkit/javascript/d3/src/svg/diagonal.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     1 d3.svg.diagonal = function() {
       
     2   var source = d3_svg_chordSource,
       
     3       target = d3_svg_chordTarget,
       
     4       projection = d3_svg_diagonalProjection;
       
     5 
       
     6   function diagonal(d, i) {
       
     7     var p0 = source.call(this, d, i),
       
     8         p3 = target.call(this, d, i),
       
     9         m = (p0.y + p3.y) / 2,
       
    10         p = [p0, {x: p0.x, y: m}, {x: p3.x, y: m}, p3];
       
    11     p = p.map(projection);
       
    12     return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
       
    13   }
       
    14 
       
    15   diagonal.source = function(x) {
       
    16     if (!arguments.length) return source;
       
    17     source = d3.functor(x);
       
    18     return diagonal;
       
    19   };
       
    20 
       
    21   diagonal.target = function(x) {
       
    22     if (!arguments.length) return target;
       
    23     target = d3.functor(x);
       
    24     return diagonal;
       
    25   };
       
    26 
       
    27   diagonal.projection = function(x) {
       
    28     if (!arguments.length) return projection;
       
    29     projection = x;
       
    30     return diagonal;
       
    31   };
       
    32 
       
    33   return diagonal;
       
    34 };
       
    35 
       
    36 function d3_svg_diagonalProjection(d) {
       
    37   return [d.x, d.y];
       
    38 }