Path: blob/master/sandbox/RFinance2014/libraries/widgets/nvd3/js/hive.js
1433 views
d3.hive = {};12d3.hive.link = function() {3var source = function(d) { return d.source; },4target = function(d) { return d.target; },5angle = function(d) { return d.angle; },6startRadius = function(d) { return d.radius; },7endRadius = startRadius,8arcOffset = -Math.PI / 2;910function link(d, i) {11var s = node(source, this, d, i),12t = node(target, this, d, i),13x;14if (t.a < s.a) x = t, t = s, s = x;15if (t.a - s.a > Math.PI) s.a += 2 * Math.PI;16var a1 = s.a + (t.a - s.a) / 3,17a2 = t.a - (t.a - s.a) / 3;18return s.r0 - s.r1 || t.r0 - t.r119? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r020+ "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r121+ "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r122+ " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r123+ " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r124+ "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r025+ "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r026+ " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r027+ " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r028: "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r029+ "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r130+ " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r131+ " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1;32}3334function node(method, thiz, d, i) {35var node = method.call(thiz, d, i),36a = +(typeof angle === "function" ? angle.call(thiz, node, i) : angle) + arcOffset,37r0 = +(typeof startRadius === "function" ? startRadius.call(thiz, node, i) : startRadius),38r1 = (startRadius === endRadius ? r0 : +(typeof endRadius === "function" ? endRadius.call(thiz, node, i) : endRadius));39return {r0: r0, r1: r1, a: a};40}4142link.source = function(_) {43if (!arguments.length) return source;44source = _;45return link;46};4748link.target = function(_) {49if (!arguments.length) return target;50target = _;51return link;52};5354link.angle = function(_) {55if (!arguments.length) return angle;56angle = _;57return link;58};5960link.radius = function(_) {61if (!arguments.length) return startRadius;62startRadius = endRadius = _;63return link;64};6566link.startRadius = function(_) {67if (!arguments.length) return startRadius;68startRadius = _;69return link;70};7172link.endRadius = function(_) {73if (!arguments.length) return endRadius;74endRadius = _;75return link;76};7778return link;79};808182