You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/website/build/javascripts/app/nodes-e55e005b.js

1 line
1.8 KiB

var Serf=Serf||{};!function(){function t(t){for(var e=p[t],i=g.select("#id_"+e.index).classed("active linkgroup_"+d,!0),r={},s=[],o=0;o<p.length;o++)if(o!=t){var a=p[o],l=g.select("#id_"+o),h=l.attr("cx")-i.attr("cx"),c=l.attr("cy")-i.attr("cy"),u=Math.sqrt(h*h+c*c);u in r?r[u].push(a):r[u]=[a],s.push(u)}for(s.sort(d3.ascending),o=0;3>o;o++){var u=s[o],a=r[u].pop(),f={source:e,target:a};m.push(f)}n()}function e(){v.attr("x1",function(t){return t.source.x}).attr("y1",function(t){return t.source.y}).attr("x2",function(t){return t.target.x}).attr("y2",function(t){return t.target.y}),y.attr("cx",function(t){return t.x}).attr("cy",function(t){return t.y})}function n(){y=y.data(p),y.enter().insert("circle",".cursor").attr("class","node").attr("r",12).attr("id",function(t,e){return"id_"+e}).call(f.drag),v=v.data(m),v.enter().insert("line",".node").attr("class","link active linkgroup_"+d),f.start(),r(d),d++}function r(t){setTimeout(s,700,t)}function s(t){g.selectAll(".linkgroup_"+t).classed("active",!1)}function o(){var t=document.getElementById("node-canvas");wW=window.innerWidth,t.style.left=(wW-l)/2+"px"}function a(){for(n(),i=0;u>i;i++)setTimeout(t,700*i+1e3,i)}var l=1400,h=490,c=50,u=128,d=0,p=[];for(i=0;u>i;i++)p.push({x:Math.random()*(l-c)+c/2,y:Math.random()*(h-c)+c/2});d3.scale.category20();var f=d3.layout.force().size([l,h]).nodes(p).linkDistance(60).charge(-1).gravity(4e-4).on("tick",e),g=d3.select("#jumbotron").append("svg").attr("id","node-canvas").attr("width",l).attr("height",h);o(),g.append("rect").attr("width",l).attr("height",h);var p=f.nodes(),m=f.links(),y=g.selectAll(".node"),v=g.selectAll(".link");g.append("circle").attr("r",30).attr("transform","translate(-100,-100)").attr("class","cursor"),window.onresize=function(){o()},Serf.Nodes={},Serf.Nodes.init=a}();