source: Dev/branches/jQueryUI/client/d3/src/svg/diagonal.js @ 249

Last change on this file since 249 was 249, checked in by hendrikvanantwerpen, 13 years ago

This one's for Subversion, because it's so close...

First widget (stripped down sequencer).
Seperated client and server code in two direcotry trees.

File size: 912 bytes
Line 
1d3.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
36function d3_svg_diagonalProjection(d) {
37  return [d.x, d.y];
38}
Note: See TracBrowser for help on using the repository browser.