3 d3.hive.link = function() {
4 var source = function(d) { return d.source; },
5 target = function(d) { return d.target; },
6 angle = function(d) { return d.angle; },
7 startRadius = function(d) { return d.radius; },
8 endRadius = startRadius,
9 arcOffset = -Math.PI / 2;
12 var s = node(source, this, d, i),
13 t = node(target, this, d, i),
15 if (t.a < s.a) x = t, t = s, s = x;
16 if (t.a - s.a > Math.PI) s.a += 2 * Math.PI;
17 var a1 = s.a + (t.a - s.a) / 3,
18 a2 = t.a - (t.a - s.a) / 3;
19 return s.r0 - s.r1 || t.r0 - t.r1
20 ? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
21 + "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r1
22 + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
23 + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
24 + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1
25 + "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r0
26 + "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r0
27 + " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r0
28 + " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
29 : "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
30 + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
31 + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
32 + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1;
35 function node(method, thiz, d, i) {
36 var node = method.call(thiz, d, i),
37 a = +(typeof angle === "function" ? angle.call(thiz, node, i) : angle) + arcOffset,
38 r0 = +(typeof startRadius === "function" ? startRadius.call(thiz, node, i) : startRadius),
39 r1 = (startRadius === endRadius ? r0 : +(typeof endRadius === "function" ? endRadius.call(thiz, node, i) : endRadius));
40 return {r0: r0, r1: r1, a: a};
43 link.source = function(_) {
44 if (!arguments.length) return source;
49 link.target = function(_) {
50 if (!arguments.length) return target;
55 link.angle = function(_) {
56 if (!arguments.length) return angle;
61 link.radius = function(_) {
62 if (!arguments.length) return startRadius;
63 startRadius = endRadius = _;
67 link.startRadius = function(_) {
68 if (!arguments.length) return startRadius;
73 link.endRadius = function(_) {
74 if (!arguments.length) return endRadius;