forked from dc-js/dc.graph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc.graph.min.js
23 lines (22 loc) · 50.3 KB
/
dc.graph.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*!
* dc.graph 0.3.16
* http://dc-js.github.io/dc.graph.js/
* Copyright 2015-2016 AT&T Intellectual Property & the dc.graph.js Developers
* https://github.com/dc-js/dc.graph.js/blob/master/AUTHORS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
!function(){function a(a,b,c){"use strict";function d(a,b,c){function d(a,b){return function(c,d){return a(c)?b(c):d()}}var e={};for(var f in c)/^node/.test(f)?a&&(e[f]=d(a,g(c[f]))):/^edge/.test(f)?b&&(e[f]=d(b,g(c[f]))):console.error('only know how to deal with properties that start with "node" or "edge"');return e}function e(a,b){return function(){return a(b.apply(null,arguments))}}function f(a){return a.orig}function g(a){return F.functor_wrap(a,f)}function h(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function i(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})}function j(a,b,c){for(var d=["M",a[0].x,",",a[0].y],e=b,f=!1,g=1;g<a.length;++g)(isNaN(a[g].x)||isNaN(a[g].y))&&(f=!0),d.push(e===b?I[b]:" ",a[g].x,",",a[g].y),0===--e&&(e=b);return e!=b&&console.log("warning: pts.length didn't match bezian degree",a,b),c&&d.push("Z"),d.join("")}function k(a,b,c,d,e,f){function g(b){var f=c(b);a[f]||e(f,a[f]={},b);var g=a[f];return d(g,b),h[f]=!0,g}e||(e=function(a,b){}),f||(f=function(a){});var h={},i=b.map(g);for(var j in a)h[j]||(f(j,a[j]),delete a[j]);return i}function l(a,b,c,d){var e=Math.tan(Math.atan2(d,c));e*=e;var f={x:a*b/Math.sqrt(b*b+a*a*e),y:a*b/Math.sqrt(a*a+b*b/e)};return c<0&&(f.x=-f.x),d<0&&(f.y=-f.y),f}function m(a,b,c){return a-J<=b&&b<=c+J}function n(a,b,c,d,e,f,g,h){var i=((a*d-b*c)*(e-g)-(a-c)*(e*h-f*g))/((a-c)*(f-h)-(b-d)*(e-g)),j=((a*d-b*c)*(f-h)-(b-d)*(e*h-f*g))/((a-c)*(f-h)-(b-d)*(e-g));if(isNaN(i)||isNaN(j))return!1;if(a>=c){if(!m(c,i,a))return!1}else if(!m(a,i,c))return!1;if(b>=d){if(!m(d,j,b))return!1}else if(!m(b,j,d))return!1;if(e>=g){if(!m(g,i,e))return!1}else if(!m(e,i,g))return!1;if(f>=h){if(!m(h,j,f))return!1}else if(!m(f,j,h))return!1;return{x:i,y:j}}function o(a,b,c,d,e){for(var f=0;f<a.length;++f){var g=f===a.length-1?0:f+1,h=n(a[f].x,a[f].y,a[g].x,a[g].y,b,c,d,e);if(h)return h}return null}function p(a,b,c,d){switch(b.dcg_shape.shape){case"ellipse":return l(b.dcg_rx,b.dcg_ry,c,d);case"polygon":return o(b.dcg_points,0,0,c,d)}}function q(a){var b=a.shape;if("random"===a.shape){var c=Object.keys(K);b=a._shape=c[Math.floor(Math.random()*c.length)]}return(K[b]||function(){throw new Error("unknown shape "+a.shape)})(a)}function r(a){return function(b){var c=a.nodeShape.eval(b)||L;b.dcg_shape=q(c),b.dcg_shape.abstract=c}}function s(a){return function(b){var c=a.nodeShape.eval(b)||L,d=b.dcg_shape.abstract;return c.shape!==d.shape||"polygon"===c.shape&&(c.shape.sides!==d.sides||c.shape.skew!==d.skew||c.shape.distortion!==d.distortion||c.shape.rotation!==d.rotation)}}function t(a){return function(a){var b,c=a.dcg_shape.shape;switch(c){case"ellipse":b="ellipse";break;case"polygon":b="path";break;default:throw new Error("unknown shape "+c)}return document.createElementNS("http://www.w3.org/2000/svg",b)}}function u(a){return function(b){var c,d=a.nodeRadius.eval(b);a.nodeFitLabel.eval(b)&&(c=this.getBBox());var e=0;if(c&&c.width&&c.height){d=Math.max(d,c.height/2+5);var f;if("ellipse"===b.dcg_shape.shape){var g=c.height/2/d;f=c.width/2/Math.sqrt(1-g*g),b.dcg_rx=Math.max(f,d),b.dcg_ry=d}else f=c.width/2,b.dcg_rx=f*Math.sqrt(2)/Math.cos(Math.PI/(b.dcg_shape.sides||4)),b.dcg_ry=d;e=2*f+a.nodePadding.eval(b)+a.nodeStrokeWidth.eval(b)}else b.dcg_rx=b.dcg_ry=d;var h=2*d+a.nodePadding.eval(b)+a.nodeStrokeWidth.eval(b);b.cola.width=Math.max(e,h),b.cola.height=h}}function v(a,b){return{rx:function(a){return a.dcg_rx},ry:function(a){return a.dcg_ry}}}function w(b,c){return{d:function(b){var c=b.dcg_shape,d=c.sides||4,e=c.skew||0,f=c.distortion||0,g=c.rotation||0,h=d%2?0:.5,i=[];g=g/360+.25;for(var k=0;k<d;++k){var l=-((k+h)/d+g)*Math.PI*2;i.push({x:Math.cos(l),y:Math.sin(l)})}var m=a.extent(i,function(a){return a.y}),n=b.dcg_rx,o=b.dcg_ry/Math.min(-m[0],m[1]);return b.dcg_points=i.map(function(a){var c=n*a.x,d=o*a.y;return c*=1+f*((b.dcg_ry-d)/b.dcg_ry-1),c-=e*d/2,{x:c,y:d}}),j(b.dcg_points,1,!0)}}}function x(b){return function(c){var d=a.select(this);switch(c.dcg_shape.shape){case"ellipse":d.attr(v(b,c));break;case"polygon":d.attr(w(b,c));break;default:throw new Error("unknown shape "+c.dcg_shape.shape)}}}function y(a,b,c){var d=100;if(a(b).val>=0)throw new Error("f(a) must be less than 0");if(a(c).val<=0)throw new Error("f(b) must be greater than 0");for(;;){if(!--d)throw new Error("patience ran out");var e=(b+c)/2,f=a(e),g=f.val;if(Math.abs(g)<.5)return f;g>0?c=e:b=e}}function z(a,b,c,d,e,f,g,h,i,j,k,l){var m,n,o,q,r,s;if(h){var t,u,v=function(b,c){return p(a,b,1e3*Math.cos(c),1e3*Math.sin(c))},w=function(a,b,c){return function(d){var e=v(a,d);return e?{port:e,val:Math.hypot(e.x-b.x,e.y-b.y)-c,ang:d}:{port:{x:0,y:0},val:0,ang:d}}},x=Math.atan2(h.sourcePort.y,h.sourcePort.x),z=Math.atan2(h.targetPort.y,h.targetPort.x);try{t=y(w(b,h.sourcePort,j),x,x+2*i*j/k)}catch(a){t={ang:x,port:h.sourcePort}}try{u=y(w(c,h.targetPort,j),z,z-2*i*j/k)}catch(a){u={ang:z,port:h.targetPort}}o=t.port,q=u.port;var A=Math.hypot(o.x,o.y),B=Math.hypot(q.x,q.y),C=A+k/2,D=B+l/2,E=d+C*Math.cos(t.ang),F=e+C*Math.sin(t.ang),G=f+D*Math.cos(u.ang),H=g+D*Math.sin(u.ang);r=[{x:d+o.x,y:e+o.y},{x:E,y:F},{x:G,y:H},{x:f+q.x,y:g+q.y}],s=3}else m=f-d,n=g-e,o=p(a,b,m,n),q=p(a,c,-m,-n),o||(o={x:0,y:0}),q||(q={x:0,y:0}),r=[{x:d+o.x,y:e+o.y},{x:f+q.x,y:g+q.y}],s=1;return{sourcePort:o,targetPort:q,points:r,bezDegree:s}}function A(a,b){for(var c=[],d=1;d<a.length;d++){var e=a[d-1],f=a[d];c.push({x:e.x+(f.x-e.x)*b,y:e.y+(f.y-e.y)*b})}return c}function B(a,b){for(var c=[a],d=1;d<a.length;d++)c.push(A(c[c.length-1],b));return c}function C(a,b){var c=B(a,b);return c[c.length-1][0]}function D(a){var b=function(){return{type:"alignment",axis:a}};return b.listname="offsets",b.wrap=function(a){return{node:a,offset:0}},b}function E(a){return(a.nodes||a.vertices)&&(a.edges||a.links)}var F={version:"0.3.16",constants:{CHART_CLASS:"dc-graph"}},G=function(a,b){void 0===b?b=f:b===!1&&(b=H);var c=a,d=null,e=[],g=function(a){return arguments.length?(d&&d(a),c=a,this):c};return g.cascade=function(a,b){for(var c=0;c<e.length;++c){if(e[c].n===a)return b?e[c].f=b:delete e[c],g;if(e[c].n>a)return e.splice(c,0,{n:a,f:b}),g}return e.push({n:a,f:b}),g},g._eval=function(a,c){if(0!==c&&e.length){var d=e[c-1];return d.f(a,function(){return g._eval(a,c-1)})}return F.functor_wrap(g(),b)(a)},g.eval=function(a){return g._eval(a,e.length)},g.react=function(a){return arguments.length?(d=a,this):d},g},H=function(a){return a};F.functor_wrap=function(a,b){return"function"==typeof a?b?function(c){return a(b(c))}:a:function(){return a}};var I={1:"L",2:"Q",3:"C"};Math.hypot=Math.hypot||function(){for(var a=0,b=arguments.length,c=0;c<b;c++){if(arguments[c]===1/0||arguments[c]===-(1/0))return 1/0;a+=arguments[c]*arguments[c]}return Math.sqrt(a)},F.depth_first_traversal=function(a){return function(b,c,d){function e(c,d){var f=b.nodeKey.eval(c);return j[f]?void(a.skip&&a.skip(c,g[f])):(i[d]||(i[d]=[]),a.place&&a.place(c,d,i[d]),i[d].push(c),j[f]=!0,h[f]&&h[f].forEach(function(b,c){c&&a.sib&&a.sib(!1,h[f][c-1].target,b.target),a.push&&a.push(),e(b.target,d+1)}),void(a.pop&&a.pop(c)))}a.init&&a.init(),a.tree&&(d=d.filter(function(b){return a.tree(b.orig)}));var f,g={},h=d.reduce(function(a,c){var d=b.edgeSource.eval(c),e=b.edgeTarget.eval(c);return a[d]||(a[d]=[]),a[d].push(c),g[e]=(g[e]||0)+1,a},{}),i=[],j={};f=a.root?c.filter(function(b){return a.root(b.orig)}):c.filter(function(a){return!g[b.nodeKey.eval(a)]}),f.forEach(function(b,c){c&&a.sib&&a.sib(!0,f[c-1],b),a.push&&a.push(),e(b,a.row?a.row(b.orig):0)}),a.finish(i)}};var J=1e-7,K={ellipse:function(){return{shape:"ellipse"}},egg:function(){return{shape:"polygon",sides:100,distortion:-.25}},triangle:function(){return{shape:"polygon",sides:3}},rectangle:function(){return{shape:"polygon",sides:4}},diamond:function(){return{shape:"polygon",sides:4,rotation:45}},trapezium:function(){return{shape:"polygon",sides:4,distortion:-.5}},parallelogram:function(){return{shape:"polygon",sides:4,skew:.5}},pentagon:function(){return{shape:"polygon",sides:5}},hexagon:function(){return{shape:"polygon",sides:6}},septagon:function(){return{shape:"polygon",sides:7}},octagon:function(){return{shape:"polygon",sides:8}},invtriangle:function(){return{shape:"polygon",sides:3,rotation:180}},invtrapezium:function(){return{shape:"polygon",sides:4,distortion:.5}},square:function(){return{shape:"polygon",sides:4}},polygon:function(a){return{shape:"polygon",sides:a.sides,skew:a.skew,distortion:a.distortion,rotation:a.rotation}}};F.available_shapes=function(){var a=Object.keys(K);return a.slice(0,a.length-1)};var L={shape:"ellipse"};return F.diagram=function(d,h){function i(){ka||(ka=new Worker("js/dc.graph."+ea.layoutAlgorithm()+".worker.js"));var a={width:ea.width(),height:ea.height()};switch(ea.layoutAlgorithm()){case"cola":Object.assign(a,{handleDisconnected:ea.handleDisconnected(),lengthStrategy:ea.lengthStrategy(),baseLength:ea.baseLength(),flowLayout:ea.flowLayout(),tickSize:ea.tickSize()});break;case"dagre":Object.assign(a,{rankdir:ea.rankdir()})}ka.postMessage({command:"init",args:a})}function l(a){return!!a.source&&!!a.target}function m(){return"none"!==ea.stageTransitions()?ea.transitionDuration()/2:ea.transitionDuration()}function n(a){return"none"===ea.stageTransitions()||"modins"===ea.stageTransitions()==!a?0:ea.transitionDuration()/2}function o(b,c){c.attr("stroke",ea.edgeStroke.eval).attr("stroke-width",ea.edgeStrokeWidth.eval).attr("marker-end",function(a){var b=ea.edgeArrowhead.eval(a),c=P(a,"head",b);return c?"url(#"+c+")":null}).attr("marker-start",function(a){var b=ea.edgeArrowtail.eval(a),c=P(a,"tail",b);return b?"url(#"+c+")":null}).each(function(b){a.selectAll("#"+ea.arrowId(b,"head")+",#"+ea.arrowId(b,"tail")).attr("fill",ea.edgeStroke.eval(b))}),ea._updateNode(b)}function p(a){la.end(a),ra=!1,ua&&(ua=!1,window.setTimeout(function(){ea.isRunning()||ea.redraw()},0))}function q(a,b,c,d,e,f){if(!a.ports[b]){var g=a.source.dcg_ry+ea.nodeStrokeWidth.eval(a.source)/2,h=a.target.dcg_ry+ea.nodeStrokeWidth.eval(a.target)/2;a.ports[b]=new Array(a.ports.n);for(var i=a.ports.rev[a.parallel],j=0;j<a.ports.n;++j){var k=!!(j%2)==c<e?-1:1,l=Math.floor((j+1)/2),m=l?a.ports[b][j>2?j-2:0].path:null,n=z(ea,a.source,a.target,c,d,e,f,m,k,ea.parallelEdgeOffset(),g,h);a.ports.rev[j]!==i&&n.points.reverse();var o=(n.points[0],n.points[n.points.length-1]),p=C(n.points,.75);a.ports[b][j]={path:n,orient:Math.atan2(o.y-p.y,o.x-p.x)+"rad"}}}return a.ports[b][a.parallel].path}function v(a){q(a,"old",a.source.prevX||a.source.cola.x,a.source.prevY||a.source.cola.y,a.target.prevX||a.target.cola.x,a.target.prevY||a.target.cola.y)}function w(a){var b=q(a,"new",a.source.cola.x,a.source.cola.y,a.target.cola.x,a.target.cola.y),c=b.points[0],d=b.points[b.points.length-1];a.length=Math.hypot(d.x-c.x,d.y-c.y)}function y(a){return function(b){var c=b.ports[a][b.parallel].path;return j(c.points,c.bezDegree)}}function A(a){return function(b){var c=b.ports[a][b.parallel].path,d=b.target.cola.x<b.source.cola.x?c.points.slice(0).reverse():c.points;return j(d,c.bezDegree)}}function B(a,b){a.every(function(a){return 0===a.size()})&&b();var c=0;a.forEach(function(a){a.each(function(){++c}).each("end.all",function(){--c||b()})})}function D(a){return{left:a.cola.x-a.dcg_rx,top:a.cola.y-a.dcg_ry,right:a.cola.x+a.dcg_rx,bottom:a.cola.y+a.dcg_ry}}function E(a,b){return{left:Math.min(a.left,b.left),top:Math.min(a.top,b.top),right:Math.max(a.right,b.right),bottom:Math.max(a.bottom,b.bottom)}}function I(a){return{left:a.x,top:a.y,right:a.x,bottom:a.y}}function J(a){var b=a.ports.new[a.parallel].path.points;return b.map(I).reduce(E)}function K(a){var b=ha.selectAll("rect.bounds").data([0]);b.enter().insert("rect",":first-child").attr({class:"bounds",fill:"rgba(128,255,128,0.1)",stroke:"#000"}),b.attr({x:a.left,y:a.top,width:a.right-a.left,height:a.bottom-a.top})}function M(a,b){(ea.fitStrategy()||ea.restrictPan())&&a.size()&&(va=a.data().map(D).reduce(E),va=b.data().map(J).reduce(E,va))}function N(){if(ea.fitStrategy()){if(!va)return;var a,b=va.right-va.left,c=va.bottom-va.top,d=ea.width(),e=ea.height();ea.DEBUG_BOUNDS&&K(va);var f,g,h=ea.fitStrategy(),i=[0,0],j=1;if(["default","vertical","horizontal"].indexOf(h)>=0){var k=e/d,l=c/b,m=l<k;"default"===h?(g=!m,f=null):(g="vertical"===h,f="xMidYMid "+(m^g?"meet":"slice")),i=[ea.margins().left,ea.margins().top],j=g?(e-ea.margins().top-ea.margins().bottom)/e:(d-ea.margins().left-ea.margins().right)/d}else if("string"==typeof h&&h.match(/^align_/)){var n=h.split("_")[1].toLowerCase().split("");if(n.length>2)throw new Error("align_ expecting 0-2 sides, not "+n.length);var o=R();i=_.translate(),j=_.scale(),n.forEach(function(a){switch(a){case"l":i[0]=S(i,o.left);break;case"t":i[1]=T(i,o.top);break;case"r":i[0]=U(i,o.right);break;case"b":i[1]=V(i,o.bottom);break;default:throw new Error("align_ expecting l t r or b, not '"+a+"'")}})}else if("function"==typeof h){var p=h(b,c,d,e);f=p.pAR,i=p.translate,j=p.scale,a=p.viewBox}else{if("string"!=typeof h)throw new Error("unknown fitStrategy type "+typeof h);f=ea.fitStrategy()}void 0!==f&&(a||(a=[va.left,va.top,b,c].join(" ")),fa.attr({viewBox:a,preserveAspectRatio:f})),_.translate(i).scale(j).event(fa)}}function O(b,c,d,e,f,g,h,i,j,k){console.assert(d.data().every(l));var o={};c.each(function(a){o[ea.nodeKey.eval(a)]=!0}).attr("transform",function(a){return"translate("+a.cola.x+","+a.cola.y+")"});var q=b.transition().duration(m()).delay(function(a){return n(o[ea.nodeKey.eval(a)])}).attr("opacity",ea.nodeOpacity.eval).attr("transform",function(a){return"translate("+a.cola.x+","+a.cola.y+")"}).each("end.record",function(a){a.prevX=a.cola.x,a.prevY=a.cola.y});d.each(function(a){a.ports.new=null,a.ports.old=null});var r={};e.each(function(a){r[ea.edgeKey.eval(a)]=!0}).each(function(b){var c;"modins"===ea.stageTransitions()?(w(b),c="new"):(v(b),c="old"),ea.edgeArrowhead.eval(b)&&a.select("#"+ea.arrowId(b,"head")).attr("orient",function(){return b.ports[c][b.parallel].orient})}).attr("d",y("modins"===ea.stageTransitions()?"new":"old"));var s=d.each(w).each(function(b){ea.edgeArrowhead.eval(b)&&a.select("#"+ea.arrowId(b,"head")).transition().duration(m()).delay(n(!1)).attr("orient",function(){return b.ports.new[b.parallel].orient})}).transition().duration(m()).delay(function(a){return n(r[ea.edgeKey.eval(a)])}).attr("opacity",ea.edgeOpacity.eval).attr("d",function(a){var b="insmod"===ea.stageTransitions()&&r[ea.edgeKey.eval(a)]?"old":"new";return y(b)(a)});k.attr("d",A("modins"===ea.stageTransitions()?"new":"old"));var t=j.transition().duration(m()).delay(function(a){return n(r[ea.edgeKey.eval(a)])}).attr("opacity",ea.edgeOpacity.eval).attr("d",function(a){var b="insmod"===ea.stageTransitions()&&r[ea.edgeKey.eval(a)]?"old":"new";return A(b)(a)});"insmod"===ea.stageTransitions()&&(m()>=50?(s=s.transition().duration(m()).attr("d",y("new")),t=t.transition().duration(m()).attr("d",A("new"))):(s.attr("d",y("new")),t.attr("d",y("new")))),ea.showLayoutSteps()||B([q,s,t],function(){p(!0)}),f.attr("d",y("new"))}function P(a,b,c){var d=ea.arrowId(a,b),e=ea.addOrRemoveDef(d,!!c,"svg:marker");return c&&e.attr("viewBox","0 -5 10 10").attr("refX",qa[c].refX).attr("refY",qa[c].refY).attr("markerUnits","userSpaceOnUse").attr("markerWidth",qa[c].width*ea.edgeArrowSize.eval(a)).attr("markerHeight",qa[c].height*ea.edgeArrowSize.eval(a)).attr("stroke",ea.edgeStroke.eval(a)).attr("fill",ea.edgeStroke.eval(a)).call(qa[c].drawFunction),c?d:null}function Q(a,b){sa=a,ta=b,ha.attr("transform","translate("+a+") scale("+b+")")}function R(){return{left:va.left-ea.margins().left,top:va.top-ea.margins().top,right:va.right+ea.margins().right,bottom:va.bottom+ea.margins().bottom}}function S(a,b){return a[0]-aa(b)+aa.range()[0]}function T(a,b){return a[1]-ba(b)+ba.range()[0]}function U(a,b){return a[0]-aa(b)+aa.range()[1]}function V(a,b){return a[1]-ba(b)+ba.range()[1]}function W(){var b=a.event.translate;if(ea.restrictPan()){var c,d=aa.domain(),e=ba.domain(),f=R(),g=f.left<d[0],h=f.right<d[1],i=f.right-f.left<d[1]-d[0],j=0;switch(g&&h?c=i?"left":"right":g||h||(c=i?"right":"left"),c){case"left":b[0]=S(b,f.left);break;case"right":b[0]=U(b,f.right);break;default:++j}switch(g=f.top<e[0],h=f.bottom<e[1],i=f.bottom-f.top<e[1]-e[0],g&&h?c=i?"top":"bottom":g||h||(c=i?"bottom":"top"),c){case"top":b[1]=T(b,f.top);break;case"bottom":b[1]=V(b,f.bottom);break;default:++j}j<2&&_.translate(b)}Q(b,a.event.scale)}function X(a,b){fa&&fa.attr("width",a||ea.width()).attr("height",b||ea.height())}function Y(){return fa=ea.root().append("svg"),X(),ga=fa.append("svg:defs"),ea.mouseZoomable()&&(aa=a.scale.linear().domain([0,ea.width()]).range([0,ea.width()]),ba=a.scale.linear().domain([0,ea.height()]).range([0,ea.height()]),_=a.behavior.zoom().on("zoom",W).x(aa).y(ba),fa.call(_),fa.on("dblclick.zoom",null)),fa}var Z,$,_,aa,ba,ca,da,ea=c.marginMixin({}),fa=null,ga=null,ha=null,ia=null,ja=null,ka=null,la=a.dispatch("end","start","drawn"),ma={},na={},oa={},pa={},qa={},ra=!1,sa=[0,0],ta=1;ea.width=G(200).react(function(a){X(a,0)}),ea.height=G(200).react(function(a){X(0,a)}),ea.root=G(null).react(function(a){a.empty()&&console.log("Warning: parent selector "+d+" doesn't seem to exist")}),ea.mouseZoomable=G(!0),ea.fitStrategy=G("default"),ea.restrictPan=G(!1),ea.autoZoom=G(null),ea.zoomToFit=function(){if(ia&&ja){var a=ia.selectAll(".node"),b=ja.selectAll(".edge");N(a,b)}},ea.nodeDimension=G(),ea.nodeGroup=G(),ea.edgeDimension=G(),ea.edgeGroup=G(),ea.nodeKey=ea.nodeKeyAccessor=G(function(a){return a.key}),ea.edgeKey=ea.edgeKeyAccessor=G(function(a){return a.key}),ea.edgeSource=ea.sourceAccessor=G(function(a){return a.value.sourcename}),ea.edgeTarget=ea.targetAccessor=G(function(a){return a.value.targetname}),ea.nodeRadius=ea.nodeRadiusAccessor=G(25),ea.nodeStrokeWidth=ea.nodeStrokeWidthAccessor=G(1),ea.nodeStroke=ea.nodeStrokeAccessor=G("black"),ea.nodeFillScale=G(null),ea.nodeFill=ea.nodeFillAccessor=G("white"),ea.nodeOpacity=G(1),ea.nodePadding=G(6),ea.nodeLabel=ea.nodeLabelAccessor=G(function(a){return a.value.label||a.value.name}),ea.nodeLabelFill=ea.nodeLabelFillAccessor=G(null),ea.nodeFitLabel=ea.nodeFitLabelAccessor=G(!0),ea.nodeShape=G(L),ea.nodeTitle=ea.nodeTitleAccessor=G(function(a){return ea.nodeKeyAccessor()(a)}),ea.nodeOrdering=G(null),ea.nodeFixed=ea.nodeFixedAccessor=G(null),ea.edgeStroke=ea.edgeStrokeAccessor=G("black"),ea.edgeStrokeWidth=ea.edgeStrokeWidthAccessor=G(1),ea.edgeOpacity=ea.edgeOpacityAccessor=G(1),ea.edgeLabel=ea.edgeLabelAccessor=G(function(a){return ea.edgeKey()(a)}),ea.edgeArrowhead=ea.edgeArrowheadAccessor=G("vee"),ea.edgeArrowtail=ea.edgeArrowtailAccessor=G(null),ea.edgeArrowSize=G(1),ea.edgeIsLayout=ea.edgeIsLayoutAccessor=G(function(a){return!a.value.notLayout}),ea.edgeIsShown=ea.edgeIsLayoutAccessor=G(!0),ea.lengthStrategy=G("symmetric"),ea.edgeLength=ea.edgeDistanceAccessor=G(function(a){return a.value.distance}),ea.flowLayout=G(null),ea.rankdir=G("TB"),ea.baseLength=G(30),ea.transitionDuration=G(500),ea.stageTransitions=G("none"),ea.deleteDelay=G(0),ea.groupConnected=G(!1),ea.timeLimit=G(0),ea.constrain=G(function(a,b){return[]}),ea.parallelEdgeOffset=G(10),ea.edgeOrdering=G(null),ea.cascade=function(a,b,c){for(var d in c){if(!ea[d])throw new Error("unknown attribute "+d);ea[d].cascade(a,b?c[d]:null)}return ea},ea.initLayoutOnRedraw=G(!1),ea.layoutUnchanged=G(!1),ea.relayout=function(){return Z=$=null,this},ea.initialLayout=G(null),ea.initialOnly=G(!1),ea.induceNodes=G(!1),ea.showLayoutSteps=G(!1),ea.legend=G(null).react(function(a){a.parent(ea)}),ea.child=function(a,b){return 1===arguments.length?pa[a]:pa[a]===b?ea:(pa[a]&&pa[a].parent(null),pa[a]=b,b&&b.parent(ea),ea)},ea.layoutAlgorithm=G("cola"),ea.tickSize=G(1),ea.edgeId=function(a){return"edge-"+ea.edgeKey.eval(a).replace(/[^\w-_]/g,"-")},ea.arrowId=function(a,b){return"arrow-"+b+"-"+ea.edgeId(a)},ea.textpathId=function(a){return"textpath-"+ea.edgeId(a)},ea.getNode=function(a){return ma[a]?ma[a].orig:null},ea.handleDisconnected=G(!0),ea._enterNode=function(a){return ea.nodeTitle()&&a.append("title"),a.each(r(ea)),a.append(t(ea)).attr("class","node-shape"),a.append("text").attr("class","node-label"),ea},ea._updateNode=function(a){var b=a.filter(s(ea));b.select(".node-shape").remove(),b.each(r(ea)),b.insert(t(ea),":first-child").attr("class","node-shape"),a.select("title").text(ea.nodeTitle.eval);var c=a.select("text.node-label"),d=c.selectAll("tspan").data(function(a){var b=ea.nodeLabel.eval(a);if(!b)return[];"string"==typeof b&&(b=[b]);var c=b.length%2?.3-(b.length-1)/2:1-b.length/2;return b.map(function(a,b){return{line:a,ofs:(0==b?c:1)+"em"}})});return d.enter().append("tspan").attr("x",0).attr("dy",function(a){return a.ofs}),d.text(function(a){return a.line}),d.exit().remove(),c.attr("fill",ea.nodeLabelFill.eval).each(u(ea)),a.select(".node-shape").each(x(ea)).attr({stroke:ea.nodeStroke.eval,"stroke-width":ea.nodeStrokeWidth.eval,fill:e(ea.nodeFillScale()||H,ea.nodeFill.eval)}),ea},ea.isRunning=function(){return ra};var ua=!1;ea.redraw=function(){return ra?(ua=!0,this):ea.startLayout()},ea.startLayout=function(){function c(a,b){a.forEach(function(a){var b=ma[a.dcg_nodeKey];b.cola.x=a.x,b.cola.y=a.y}),b.forEach(function(a){na[a.dcg_edgeKey]})}var d=ea.nodeGroup().all(),e=ea.edgeGroup().all();if(ra)throw new Error("dc_graph.diagram.redraw already running!");ra=!0,ka&&ka.postMessage({command:"stop"}),ea.initLayoutOnRedraw()&&i(),ea.nodeOrdering()&&(d=b.quicksort.by(ea.nodeOrdering())(d.slice(0),0,d.length)),ea.edgeOrdering()&&(e=b.quicksort.by(ea.edgeOrdering())(e.slice(0),0,e.length));var h=k(ma,d,function(a){return ea.nodeKey()(a)},function(a,b){a.orig=b,a.cola=a.cola||{},a.cola.dcg_nodeKey=ea.nodeKey.eval(a),ea.nodeFixed()&&(a.cola.dcg_nodeFixed=ea.nodeFixed.eval(a))}),j=k(na,e,function(a){return ea.edgeKey()(a)},function(a,b){a.orig=b,a.cola=a.cola||{},a.cola.dcg_edgeKey=ea.edgeKey.eval(a),a.cola.dcg_edgeSource=ea.edgeSource.eval(a),a.cola.dcg_edgeTarget=ea.edgeTarget.eval(a),a.source=ma[a.cola.dcg_edgeSource],a.target=ma[a.cola.dcg_edgeTarget],a.cola.dcg_edgeLength=ea.edgeLength.eval(a)});if(j=j.filter(l),j=j.filter(function(a){return a.source!==a.target}),j=j.filter(ea.edgeIsShown.eval),ea.induceNodes()){var n={};j.forEach(function(a){n[a.cola.dcg_edgeSource]=!0,n[a.cola.dcg_edgeTarget]=!0}),h=h.filter(function(a){return n[a.cola.dcg_nodeKey]});for(var q in ma)n[q]||delete ma[q]}if(h.forEach(function(a,b){a.index=b}),oa={nnodes:h.length,nedges:j.length},ea.parallelEdgeOffset()){for(var r=new Array(h.length),s=0;s<r.length;++s){r[s]=new Array(r.length);for(var t=0;t<r.length;++t)r[s][t]={n:0,ports:{rev:[]}}}for(j.forEach(function(a){var b=Math.min(a.source.index,a.target.index),c=Math.max(a.source.index,a.target.index);a.parallel=r[b][c].n++,a.ports=r[b][c].ports,a.ports.rev.push(b!==a.source.index)}),s=0;s<r.length;++s)for(t=0;t<r.length;++t)r[s][t].n&&(r[s][t].ports.n=r[s][t].n)}var u=ja.selectAll(".edge").data(j,ea.edgeKey.eval),v=u.enter().append("svg:path").attr({class:"edge",id:ea.edgeId,opacity:0});u.exit().transition().duration(m()).delay(ea.deleteDelay()).attr("opacity",0).each(function(a){P(a,"head",null),P(a,"head",null)}).remove();var w=ja.selectAll(".edge-hover").data(j,ea.edgeKey.eval),x=w.enter().append("svg:path").attr("class","edge-hover").attr("opacity",0).attr("stroke","green").attr("stroke-width",10).on("mouseover",function(b){a.select("#"+ea.edgeId(b)+"-label").attr("visibility","visible")}).on("mouseout",function(b){a.select("#"+ea.edgeId(b)+"-label").attr("visibility","hidden")});w.exit().remove();var y=ja.selectAll(".edge-label").data(j,ea.edgeKey.eval),z=y.enter().append("text").attr("id",function(a){return ea.edgeId(a)+"-label"}).attr("visibility","hidden").attr({class:"edge-label","text-anchor":"middle",dy:-2}).append("textPath").attr("startOffset","50%").attr("xlink:href",function(a){var b=ea.textpathId(a);return"#"+b}),A=ga.selectAll("path.edge-label-path").data(j,ea.textpathId),B=A.enter().append("svg:path").attr({class:"edge-label-path",id:ea.textpathId});y.each(function(a){a.dcg_bbox=null}).selectAll("textPath").text(function(a){return ea.edgeLabel.eval(a)}),y.exit().transition().duration(m()).delay(ea.deleteDelay()).attr("opacity",0).remove();var C=ia.selectAll(".node").data(h,ea.nodeKey.eval),D=C.enter().append("g").attr("class","node").attr("opacity","0");ea._enterNode(D),C.exit().transition().duration(m()).delay(ea.deleteDelay()).attr("opacity",0).remove(),la.drawn(C,u,w),o(C,u),ea.initialLayout()&&ea.initialLayout()(ea,h,j);var E=!1;if(!ea.layoutUnchanged()){var G=JSON.stringify(h.map(f)),H=JSON.stringify(j.map(f));G===Z&&H===$&&(E=!0),Z=G,$=H}var I=ea.constrain()(ea,h,j);I.forEach(function(a){if(a.type)switch(a.type){case"alignment":a.offsets.forEach(function(a){a.node=ma[a.node].index});break;case"circle":a.nodes.forEach(function(a){a.node=ma[a.node].index})}else a.axis&&(a.left=ma[a.left].index,a.right=ma[a.right].index)});var J=j.filter(ea.edgeIsLayout.eval),K=(j.filter(function(a){return!ea.edgeIsLayout.eval(a)}),I.filter(function(a){return"circle"===a.type}));I=I.filter(function(a){return"circle"!==a.type}),K.forEach(function(a){var b=(a.distance||4*ea.baseLength())/(2*Math.sin(Math.PI/a.nodes.length)),c=a.nodes.map(function(a){return a.node}),d=function(a){return ea.nodeKey.eval(h[a])},e=F.wheel_edges(d,c,b).map(function(a){var b={internal:a};return b.source=ma[a.sourcename],b.target=ma[a.targetname],b});J=J.concat(e)});var L=I.filter(function(a){return"ordering"===a.type});if(I=I.filter(function(a){return"ordering"!==a.type}),L.forEach(function(a){var c=a.nodes.map(function(a){return ma[a]});if(a.ordering){var d=b.quicksort.by(g(a.ordering));c=d(c,0,c.length)}var e;c.forEach(function(b,c){0===c?e=b:I.push({left:e.index,right:(e=b).index,axis:a.axis,gap:a.gap})})}),ea.legend()&&ea.legend().redraw(),E)return ra=!1,la.end(!1),this;var Q=Date.now();return ka.onmessage=function(a){var b=a.data.args;switch(a.data.response){case"tick":var d=Date.now()-Q;c(b.nodes,b.edges),ea.showLayoutSteps()&&O(C,D,u,v,w,x,y,z,A,B),(ua||ea.timeLimit()&&d>ea.timeLimit())&&(console.log("cancelled"),ka.postMessage({command:"stop"}));break;case"end":ea.showLayoutSteps()?p(!0):(c(b.nodes,b.edges),O(C,D,u,v,w,x,y,z,A,B));var e;switch(ea.autoZoom()){case"always":e=!0;break;case"once":e=!0,ea.autoZoom(null);break;default:e=!1}M(C,u),e&&N();break;case"start":console.log("algo "+ea.layoutAlgorithm()+" started."),la.start()}},la.start(),ka.postMessage({command:"data",args:{nodes:h.map(function(a){return a.cola}),edges:J.map(function(a){return a.cola}),constraints:I,opts:{groupConnected:ea.groupConnected()}}}),ka.postMessage({command:"start",args:{initialUnconstrainedIterations:10,initialUserConstraintIterations:20,initialAllConstraintsIterations:20,initialOnly:ea.initialOnly(),showLayoutSteps:ea.showLayoutSteps()}}),this},ea.refresh=function(b,c,d,e,f){b=b||ia.selectAll(".node"),c=c||ja.selectAll(".edge"),o(b,c),d=d||ja.selectAll(".edge-hover"),e=e||ja.selectAll(".edge-label"),f=f||ga.selectAll("path.edge-label-path");var g=a.select(null);O(b,g,c,g,d,g,e,g,f,g)};var va;return ea.render=function(){return ea.initLayoutOnRedraw()||i(),ea.resetSvg(),ha=fa.append("g"),ja=ha.append("g"),ia=ha.append("g"),ea.legend()&&ea.legend().render(),ea.redraw()},ea.on=function(a,b){return la.on(a,b),this},ea.getStats=function(){return oa},ea.select=function(a){return ea.root().select(a)},ea.selectAll=function(a){return ea.root()?ea.root().selectAll(a):null},ea.svg=function(a){return arguments.length?(fa=a,ea):fa},ea.resetSvg=function(){return ea.select("svg").remove(),Y()},ea.redrawGroup=function(){c.redrawAll(h)},ea.renderGroup=function(){c.renderAll(h)},ea.defineArrow=function(a,b,c,d,e,f){return qa[a]={name:a,width:b,height:c,refX:d,refY:e,drawFunction:f},ea},ea.addOrRemoveDef=function(a,b,c){var d=b?[0]:[],e=ga.selectAll("#"+a).data(d),f=e.enter().append(c).attr("id",a);return e.exit().remove(),f},ea.invertCoord=function(a){return[aa.invert(a[0]),ba.invert(a[1])]},ea.defineArrow("vee",12,12,10,0,function(a){a.append("svg:path").attr("d","M0,-5 L10,0 L0,5 L3,0").attr("stroke-width","0px")}),ea.defineArrow("dot",7,7,0,0,function(a){a.append("svg:circle").attr("r",5).attr("cx",5).attr("cy",0).attr("stroke-width","0px")}),ea.anchor=function(b,d){if(!arguments.length)return ca;if(!b)throw new c.errors.BadArgumentException("parent must be defined");return ca=b.select&&b.classed?b.node():b,ea.root(a.select(ca)),ea.root().classed(F.constants.CHART_CLASS,!0),c.registerChart(ea,d),da=d,ea},ea.anchorName=function(){var a=ea.anchor();return a&&a.id?a.id:a&&a.replace?a.replace("#",""):"dc-graph"+ea.chartID()},ea.anchor(d,h)},F.legend=function(){var a,b={};return b.x=G(0),b.y=G(0),b.gap=G(5),b.nodeWidth=G(40),b.nodeHeight=G(40),b.exemplars=G({}),b.parent=G(null),b.redraw=function(){var c=b.parent().svg().selectAll("g.dc-graph-legend").data([0]);c.enter().append("g").attr("class","dc-graph-legend").attr("transform","translate("+b.x()+","+b.y()+")");var d=c.selectAll(".node").data(a,function(a){return a.name}),e=d.enter().append("g").attr("class","node");e.append("text").attr("dy","0.3em").attr("class","legend-label"),d.attr("transform",function(a,c){return"translate("+b.nodeWidth()/2+","+(b.nodeHeight()+b.gap())*(c+.5)+")"}),d.select("text.legend-label").attr("transform","translate("+(b.nodeWidth()/2+b.gap())+",0)").text(function(a){return a.name}),b.parent()._enterNode(e)._updateNode(d)},b.render=function(){var c=b.exemplars();if(c instanceof Array)a=c.map(function(a){return{name:a.name,orig:{key:a.key,value:a.value},cola:{}}});else{a=[];for(var d in c)a.push({name:d,orig:{key:d,value:c[d]},cola:{}})}b.redraw()},b},F.constraint_pattern=function(a){var b={},c=[];return a.nodes.forEach(function(a){var c=a.id,d=b[c]||(b[c]={});if(a.partition){var e=a.partition,f=a.value||a.id;a.all||a.typename?(d.match=a.extract?function(b){return a.extract(b.value[e])}:function(a){return a.value[e]},d.typename=a.typename||function(a){return e+"="+a.value[e]}):d.match=function(a){return a.value[e]===f}}else{if(!a.match)throw new Error("couldn't determine matcher for type "+JSON.stringify(a));d.match=a.match}}),a.edges.forEach(function(a){if(!a.disable){var b={source:a.source,target:a.target};b.produce="function"==typeof a.produce?a.produce:function(){return h(a.produce)},["listname","wrap","reverse"].forEach(function(c){void 0!==a[c]&&(b[c]=a[c])}),c.push(b)}}),function(a,d,e){var f=[],g={};d.forEach(function(c){var d=a.nodeKey.eval(c);for(var e in b){var f=b[e],h=f.match(c.orig);if(h){var i=f.typename?f.typename(e,h):e;g[i]||(g[i]={nodes:[],whether:{}}),g[i].nodes.push(d),g[i].whether[d]=!0}}});var h=c.filter(function(a){return a.source!==a.target}),i=c.filter(function(a){return a.source===a.target});return e.forEach(function(b){var c=a.edgeSource.eval(b),i=a.edgeTarget.eval(b);h.forEach(function(a){if(g[a.source]&&g[a.source].whether[c]&&g[a.target]&&g[a.target].whether[i]){var b=a.produce(g,d,e);a.reverse?(b.left=i,b.right=c):(b.left=c,b.right=i),f.push(b)}})}),i.forEach(function(a){if(g[a.source]){var b=a.produce(),c=a.listname||a.produce.listname||"nodes",d=a.wrap||a.produce.wrap||function(a){return a};b[c]=g[a.source].nodes.map(d),f.push(b)}}),f}},F.gap_y=function(a,b){return{axis:"y",gap:a,equality:!!b}},F.gap_x=function(a,b){return{axis:"x",gap:a,equality:!!b}},F.align_y=function(){return D("y")},F.align_x=function(){return D("x")},F.order_x=function(a,b){return{type:"ordering",axis:"x",gap:60,ordering:b}},F.order_y=function(a,b){return{type:"ordering",axis:"y",gap:60,ordering:b}},F.tree_constraints=function(a,b,c,d){return function(d,e,f){var g=[],h=0,i=F.depth_first_traversal({root:a,tree:b,place:function(a,b,c){if(c.length){var e=c[c.length-1];g.push({left:d.nodeKey.eval(e),right:d.nodeKey.eval(a),axis:"x",gap:h-e.foo_x,equality:!0})}a.foo_x=h},sib:function(){h+=c}});return i(d,e,f),g}},F.tree_positions=function(b,c,d,e,f,g,h){function i(a,b){return(g(a)+g(b))/2;
}var j;g=a.functor(g);var k=F.depth_first_traversal({init:function(){j=e},root:b,row:c,tree:d,place:function(a,b,c){if(c.length){var d=c[c.length-1],e=(g(d)+g(a))/2;j=Math.max(j,d.left_x+e)}a.left_x=j,a.hit_ins=1,a.cola.y=b*h+f},sib:function(a,b,c){var d=i(b,c);a&&(d*=1.5),j+=d},pop:function(a){a.cola.x=(a.left_x+j)/2},skip:function(a,b){a.cola.x=(a.hit_ins*a.cola.x+j)/++a.hit_ins,a.hit_ins===b&&delete a.hit_ins},finish:function(a){a.forEach(function(a){for(var b,c=a.sort(function(a,b){return a.cola.x-b.cola.x}),d=null,e=null,f=0;f<c.length-1;++f){var g=c[f],h=c[f+1];if(d){if(b+=i(g,h),f<c.length-2&&h.cola.x<e+b)continue;d>0&&--d;var j,k;if(f<c.length-2){var l=h.cola.x-(e+b);j=c[d].cola.x+l/2,k=f+1}else j=Math.max(c[d].cola.x,e-i(c[d],c[d+1])-(b-h.cola.x+e)/2),k=c.length;for(var m=d+1;m<k;++m)j+=i(c[m-1],c[m]),c[m].cola.x=j;d=e=b=null}else h.cola.x-g.cola.x<i(g,h)&&(d=f,e=g.cola.x,b=i(g,h))}})}});return k},F.behavior=function(a,b){var c={};return c.parent=G(null).react(function(d){var e;if(d){var f=!0;e=d,d.on("drawn."+a,function(a,c,d){b.add_behavior(e,a,c,d),f&&b.first?(b.first(e,a,c,d),f=!1):b.rest&&b.rest(e,a,c,d)})}else c.parent()&&(e=c.parent(),e.on("drawn."+a,function(c,d,f){b.remove_behavior(e,c,d,f),e.on("drawn."+a,null)}));b.parent&&b.parent(d)}),c},F.tip=function(){function b(b){return function(c){var d=a.event.target,h=function(){f[b]()(c,function(a){g.show(a,d)})};f.delay()?(clearTimeout(e),e=setTimeout(h,f.delay())):h()}}function c(){e&&(clearTimeout(e),e=null),g.hide()}function d(d,e){g||(g=a.tip().attr("class","d3-tip").html(function(a){return"<span>"+a+"</span>"}).direction(f.direction()),f.parent().svg().call(g)),d.on("mouseover.tip",b("content")).on("mouseout.tip",c),e.on("mouseover.tip",b("content")).on("mouseout.tip",c)}var e,f={},g=null;return f.parent=G(null).react(function(a){a?a.on("drawn.tip",function(a,b,c){d(a,c)}):f.parent()&&f.parent().on("drawn.tip",null)}),f.direction=G("n"),f.content=G(function(a,b){b(f.parent()?f.parent().nodeTitle.eval(a):"")}),f.delay=G(0),f},F.tip.table=function(){var b=function(c,d){c=c.orig.value;var e=Object.keys(c).filter(a.functor(b.filter())).filter(function(a){return c[a]}),f=a.select(document.createElement("table")),g=f.selectAll("tr").data(e),h=g.enter().append("tr");h.append("td").text(function(a){return a}),h.append("td").text(function(a){return c[a]}),d(f.node().outerHTML)};return b.filter=G(!0),b},F.select_nodes=function(b){function c(c,e,h){c.cascade(50,!0,d(function(a){return g.indexOf(a.orig.key)>=0},null,b)),e.on("click.select-nodes",function(b){g=[c.nodeKey.eval(b)],c.refresh(e,h),f.node_set_changed(g),a.event.stopPropagation()}),c.svg().on("click.select-nodes",function(a){g=[],c.refresh(e,h),f.node_set_changed(g)});var i=e.data().map(function(a){return a.orig.key}),j=g.length;g=g.filter(function(a){return i.indexOf(a)>=0}),g.length!==j&&f.node_set_changed(g)}function e(a,c,d){c.on("click.select-nodes",null),a.svg().on("click.select-nodes",null),a.cascade(50,!1,b)}var f=F.select_nodes_group("select-nodes-group"),g=[];return F.behavior("select-nodes",{add_behavior:c,remove_behavior:function(a,b,c){e(a,b,c)}})},F.select_nodes_group=function(b){return window.chart_registry.create_type("select-nodes",function(){return a.dispatch("node_set_changed")}),window.chart_registry.create_group("select-nodes",b)},F.highlight_neighbors=function(a){function b(a){a.each(function(a){a.dcg_highlighted=!1})}function c(c,e,f){c.cascade(100,!0,d(null,function(a){return a.dcg_highlighted},a)),e.on("mouseover.highlight-neighbors",function(a){f.each(function(b){b.dcg_highlighted=b.source===a||b.target===a}),c.refresh(e,f)}).on("mouseout.highlight-neighbors",function(a){b(f),c.refresh(e,f)})}function e(c,d,e){d.on("mouseover.highlight-neighbors",null).on("mouseout.highlight-neighbors",null),b(e),c.cascade(100,!1,a)}return F.behavior("highlight-neighbors",{add_behavior:c,remove_behavior:function(a,b,c){e(a,b,c)}})},F.register_highlight_paths_group=function(b){return window.chart_registry.create_type("highlight-paths",function(){return a.dispatch("paths_changed","hover_changed","select_changed")}),window.chart_registry.create_group("highlight-paths",b)},F.highlight_paths=function(a,b,c,e){function f(){v.doRedraw()?v.parent().relayout().redraw():v.parent().refresh()}function g(a,b){r=a,s=b,t=u=null,f()}function h(a){a!==u&&(u=a,f())}function i(a){a!==t&&(t=a,f())}function j(){r={},s={}}function k(a){return function(b){return a.indexOf(b)>=0}}function l(a){var b=k(a);return function(a){return!b(a)}}function m(a,b){return!(!a||!b)&&a.some(k(b))}function n(a,b){return a?b?b.every(k(a))?a.filter(l(b)):a.concat(b.filter(l(a))):a:b}function o(e,f,g,h){e.cascade(200,!0,d(function(a){return!!r[e.nodeKey.eval(a)]},function(a){return!!s[e.edgeKey.eval(a)]},a)).cascade(300,!0,d(function(a){return m(r[e.nodeKey.eval(a)],t)},function(a){return m(s[e.edgeKey.eval(a)],t)},c)).cascade(400,!0,d(function(a){return m(r[e.nodeKey.eval(a)],u)},function(a){return m(s[e.edgeKey.eval(a)],u)},b)),f.on("mouseover.highlight-paths",function(a){q.hover_changed(r[e.nodeKey.eval(a)]||null)}).on("mouseout.highlight-paths",function(a){q.hover_changed(null)}).on("click.highlight-paths",function(a){q.select_changed(n(t,r[e.nodeKey.eval(a)]))}),h.on("mouseover.highlight-paths",function(a){q.hover_changed(s[e.edgeKey.eval(a)]||null)}).on("mouseout.highlight-paths",function(a){q.hover_changed(null)}).on("click.highlight-paths",function(a){q.select_changed(n(t,s[e.nodeKey.eval(a)]))})}function p(d,e,f,g){e.on("mouseover.highlight-paths",null).on("mouseout.highlight-paths",null).on("click.highlight-paths",null),g.on("mouseover.highlight-paths",null).on("mouseout.highlight-paths",null).on("click.highlight-paths",null),j(),d.cascade(200,!1,a).cascade(300,!1,c).cascade(400,!1,b)}var q=F.register_highlight_paths_group(e||"highlight-paths-group");a=a||{},b=b||{},c=c||{};var r={},s={},t=null,u=null,v=F.behavior("highlight-paths",{add_behavior:o,remove_behavior:function(a,b,c,d){return p(a,b,c,d),this},parent:function(a){var b=a.anchorName();q.on("paths_changed."+b,a?g:null),q.on("hover_changed."+b,a?h:null),q.on("select_changed."+b,a?i:null)}});return v.doRedraw=G(!1),v},F.expand_collapse=function(b,c,d,e){function f(a){var b=a.addOrRemoveDef("spike-gradient",!0,"linearGradient");b.attr({x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"}),b.selectAll("stop").data([[0,"black",1],[100,"black","0"]]).enter().append("stop").attr({offset:function(a){return a[0]+"%"},"stop-color":function(a){return a[1]},"stop-opacity":function(a){return a[2]}})}function g(a,b,c,d){var e;switch(c){case"out":e=function(b){return a.edgeSource.eval(b)===d};break;case"in":e=function(b){return a.edgeTarget.eval(b)===d};break;case"both":e=function(b){return a.edgeSource.eval(b)===d||a.edgeTarget.eval(b)===d}}return b.filter(e).size()}function h(a,b,c){if("both"===b)return function(a){return Math.PI*(2*a/c-.5)};var d,e=(c-1)*Math.PI/c;switch(a){case"LR":d=0;break;case"TB":d=Math.PI/2;break;case"RL":d=Math.PI;break;case"BT":d=-Math.PI/2}return"in"===b&&(d+=Math.PI),function(a){return d+e*(-.5+(c>1?a/(c-1):0))}}function i(a,b,c){var d=b.selectAll("g.spikes").data(function(a){return!a.dcg_expand_selected||a.dcg_expanded&&a.dcg_expanded[a.dcg_expand_selected.dir]?[]:[a]});d.exit().remove(),d.enter().insert("g",":first-child").classed("spikes",!0);var e=d.selectAll("rect.spike").data(function(b){for(var c=(a.nodeKey.eval(b),b.dcg_expand_selected.dir),d=b.dcg_expand_selected.n,e=h(a.rankdir(),c,d),f=Array(d),g=0;g<d;++g){var i=e(g);f[g]={a:180*i/Math.PI,x:Math.cos(i)*b.dcg_rx*.9,y:Math.sin(i)*b.dcg_ry*.9}}return f});e.enter().append("rect").classed("spike",!0).attr({width:25,height:3,fill:"url(#spike-gradient)",rx:1,ry:1,x:0,y:0}),e.attr("transform",function(a){return"translate("+a.x+","+a.y+") rotate("+a.a+")"}),e.exit().remove()}function j(a,b,c){b.each(function(a){a.dcg_expand_selected=null}),i(a,b,c)}function k(a,b,c,d){return 1===g(a,b,d,c)}function l(a,b,c,d){if(1===c.length)return c[0];var e=a.root().node().getBoundingClientRect(),f=a.invertCoord([b.clientX-e.left,b.clientY-e.top]),g=f[0],h=f[1];switch(a.rankdir()){case"TB":return h>d.cola.y?"out":"in";case"BT":return h<d.cola.y?"out":"in";case"LR":return g>d.cola.x?"out":"in";case"RL":return g<d.cola.x?"out":"in"}throw new Error("unknown rankdir "+a.rankdir())}function m(f,h,m){function n(c){var d=l(f,a.event,e,c),j=f.nodeKey.eval(c);Promise.resolve(b(j,d)).then(function(a){var b={dir:d,n:Math.max(0,a-g(f,m,d,j))};h.each(function(a){a.dcg_expand_selected=a===c?b:null}),i(f,h,m)})}function o(b){function g(){var a=l(f,j,e,b);b.dcg_expanded=b.dcg_expanded||{},b.dcg_expanded[a]?(d(f.nodeKey.eval(b),k.bind(null,f,m,a),a),b.dcg_expanded[a]=!1):(c(f.nodeKey.eval(b),a,"dblclick"===j.type),b.dcg_expanded[a]=!0),i(f,h,m),b.dcg_dblclk_timeout=null}var j=a.event;return console.log(j.type),g()}h.on("mouseover.expand-collapse",n).on("mousemove.expand-collapse",n).on("mouseout.expand-collapse",function(a){j(f,h,m)}).on("click",o).on("dblclick",o)}function n(a,b,c){b.on("mouseover.expand-collapse",null).on("mouseout.expand-collapse",null),j(a,b)}if(e=e||["both"],e.length>2)throw new Error("there are only two directions to expand in");return F.behavior("expand-collapse",{add_behavior:m,first:f,remove_behavior:n})},F.load_graph=function(){function b(a){return a?a.replace(/\?.*/,""):null}var c,d,e;if(c=arguments[0],3===arguments.length)d=arguments[1],e=arguments[2];else{if(2!==arguments.length)throw new Error("need two or three arguments");e=arguments[1]}d?queue().defer(a.json,c).defer(a.json,d).await(function(a,b,c){a?e(a,null):e(null,{nodes:b.results,edges:c.results})}):/\.json$/.test(b(c))?a.json(c,e):/\.gv|\.dot$/.test(b(c))&&a.text(c,function(a,b){if(a)return void e(a,null);var c=graphlibDot.parse(b),d=c.nodes(),f=new Array(d.length);d.forEach(function(a,b){var e=f[b]=c._nodes[d[b]];e.id=b,e.name=a});var g=c.edges(),h=[];g.forEach(function(a){var b=c._edges[a];h.push({source:c._nodes[b.u].id,target:c._nodes[b.v].id,sourcename:b.u,targetname:b.v})});var i={nodes:f,links:h};e(null,i)})},F.munge_graph=function(a,b,c,d){function e(a,b){return b.filter(function(b){return!!a[b]})}var f,g,h=b||"name",i=c||"sourcename",j=d||"targetname";if(!E(a)){var k=["database","response"],l=k.findIndex(function(b){return a[b]&&E(a[b])});if(l<0)throw new Error("couldn't find the data!");a=a[k[l]]}g=a.edges||a.links,f=a.nodes||a.vertices;var m=g[0];if(void 0===m[i]){var n=c?[c]:["source_ecomp_uid","node1","source","tail"],o=d?[d]:["target_ecomp_uid","node2","target","head"],p=["edge"];if(m.node0&&m.node1)i="node0",j="node1";else{var q=e(m,n);if(!q.length){if(l=p.findIndex(function(a){return m[a]&&e(m[a],n).length}),l<0)throw c?new Error("sourceattr "+i+" didn't work"):new Error("didn't find any source attr");g=g.map(function(a){return a[p[l]]}),m=g[0],q=e(m,n)}if(q.length>1&&console.warn("found more than one possible source attr",q),i=q[0],q=e(m,o),!q.length)throw d&&!m[d]?new Error("targetattr "+j+" didn't work"):new Error("didn't find any target attr");q.length>1&&console.warn("found more than one possible target attr",q),j=q[0]}}var r=f[0];if(void 0===r[h]){var s=b?[b]:["ecomp_uid","id","_id"],t=["vertex"];if(q=e(r,s),!q.length){if(l=t.findIndex(function(a){return r[a]&&e(r[a],s).length}),l<0)throw b?new Error("nodekeyattr "+h+" didn't work"):new Error("couldn't find the node data");f=f.map(function(a){return a[t[l]]}),r=f[0],q=e(r,s)}q.length>1&&console.warn("found more than one possible node key attr",q),h=q[0]}return{nodes:f,edges:g,nodekeyattr:h,sourceattr:i,targetattr:j}},F.flat_group=function(){function a(a){return{all:function(){return a.all().filter(function(a){return null!==a.value})}}}function c(b,c){var e=b.dimension(c);return{crossfilter:b,dimension:e,group:a(e.group().reduce(d.add,d.remove,d.init))}}var d={add:function(a,b){return b},remove:function(){return null},init:function(){return null}};return{make:function(a,d){var e=b(a);return c(e,d)},another:function(a,b){return c(a,b)}}}(),F.convert_nest=function(a,b,d,e,f,g,j){j=j||{};var k=Object.keys(j).length;if(b.length){var l=b.shift(),m=[],n=[],o=a.map(function(a){j[l]=a.key;var c=i(),o=h(j);if(o[d]=c,o.name=l+":"+a.key,o._level=k+1,m.push(o),g){var p={};p[e]=g,p[f]=c,n.push(p)}var q=F.convert_nest(a.values,b.slice(0),d,e,f,c,h(j));return q});return{nodes:Array.prototype.concat.apply(m,o.map(c.pluck("nodes"))),edges:Array.prototype.concat.apply(n,o.map(c.pluck("edges")))}}return{nodes:a.map(function(a){return a._level=k+1,a}),edges:a.map(function(a){var b={};return b[e]=g,b[f]=a[d],b})}},F.convert_adjacency_list=function(a,b,c){var d=Array.prototype.concat.apply([],a.map(function(a){return a[b.adjacencies].map(function(d){var e={};return c.edgeKey&&(e[c.edgeKey]=i()),e[c.edgeSource]=a[b.nodeKey],e[c.edgeTarget]=b.targetKey?d[b.targetKey]:d,c.adjacency&&(e[c.adjacency]=d),e})}));return{nodes:a,edges:d}},F.path_reader=function(a){function b(a,b,c){g.elementList.eval(a).forEach(function(d){var e,f;switch(g.elementType.eval(d)){case"node":e=g.nodeKey.eval(d),f=b[e]=b[e]||[];break;case"edge":e=g.edgeSource.eval(d)+"-"+g.edgeTarget.eval(d),f=c[e]=c[e]||[]}f.push(a)})}var c,d,e,f=F.register_highlight_paths_group(a||"highlight-paths-group"),g={pathList:G(H,!1),timeRange:G(null,!1),elementList:G(H,!1),elementType:G(null,!1),nodeKey:G(null,!1),edgeSource:G(null,!1),edgeTarget:G(null,!1),clear:function(){f.paths_changed({},{},[])},data:function(a){var h,i={},j={},k=[];g.pathList.eval(a).forEach(function(a){if(a._range=g.timeRange.eval(a)){if(h===!1)throw new Error("can't have a mix of ranged and non-ranged paths");h=!0}else{if(h===!0)throw new Error("can't have a mix of ranged and non-ranged paths");h=!1,b(a,i,j)}k.push(a)}),h?(c=k.map(function(a){var b=[a._range[0].getTime(),a._range[1].getTime()];return b.path=a,b}),d=lysenkoIntervalTree(c),e&&this.setTime(e)):(c=null,d=null,f.paths_changed(i,j,k))},getIntervals:function(){return c},setTime:function(a){if(a&&d){var c=[],g={},h={};d.queryPoint(a.getTime(),function(a){c.push(a.path),b(a.path,g,h)}),f.paths_changed(g,h,c)}e=a}};return g},F.path_selector=function(b,d,e,f){function g(a){return function(b){return!!a&&a.indexOf(b)>=0}}function h(a){var b=g(a);return function(a){return!b(a)}}function i(a,b){return a?b?b.every(g(a))?a.filter(h(b)):a.concat(b.filter(h(a))):a:b}function j(a){var b=n.selectAll("span.path-selector").data(a);b.enter().append("span").attr("class","path-selector").style({"border-width":"1px","border-style":"solid","border-color":"grey","border-radius":"4px",display:"inline-block",padding:"4px",cursor:"pointer",margin:"5px"}),b.exit().transition(1e3).attr("opacity",0).remove(),b.text(function(a,b){return"path "+(b+1)+" ("+d.elementList.eval(a).length+")"}).on("mouseover",function(a){m.hover_changed([a])}).on("mouseout",function(a){m.hover_changed(null)}).on("click",function(a){m.select_changed(i(q,[a]))});var c=n.selectAll("span.no-paths").data(0===a.length?[0]:[]);c.exit().remove(),c.enter().append("span").attr("class","no-paths"),c.classed("error",!!r.error_text()).text(r.error_text()||(r.queried()?r.zero_text():r.default_text()))}function k(){var a=g(p);n.selectAll("span.path-selector").style({"border-color":function(b,c){return a(b)?"#e41a1c":"grey"},"border-width":function(b,c){return(a(b)?2:1)+"px"},padding:function(b,c){return(a(b)?3:4)+"px"}})}function l(){var a=g(q);n.selectAll("span.path-selector").style({"background-color":function(b,c){return a(b)?"#1c1ae6":"white"},color:function(b,c){return a(b)?"white":"black"}})}var m=F.register_highlight_paths_group(e||"highlight-paths-group"),n=a.select(b),o=[],p=null,q=null;m.on("paths_changed.selector",function(a,b,c){p=q=null,o=c,r.redraw()}).on("hover_changed.selector",function(a){p=a,k()}).on("select_changed.selector",function(a){q=a,l()});var r={default_text:G("Nothing here"),zero_text:G("No paths"),error_text:G(null),queried:G(!1),redraw:function(){j(o),k(),l()},render:function(){return this.redraw(),this}};return c.registerChart(r,f),r},F.node_name=function(a){if(a<26)return String.fromCharCode(97+a);if(a<52)return String.fromCharCode(65+a-26);if(a<2704)return F.node_name(Math.floor(a/52))+F.node_name(a%52);throw new Error("no, that's too large")},F.node_object=function(a,b){return b=b||{},_.extend({id:a,name:F.node_name(a)},b)},F.edge_object=function(a,b,c,d){return d=d||{},_.extend({source:b,target:c,sourcename:a(b),targetname:a(c)},d)},F.generate=function(a,b,c,d){var e,f,g,h,i=c.nodePrefix||"",j=function(a){return e[a].name},k=b[0],l=c.linkLength||30;switch(a){case"clique":case"cliquestf":for(e=new Array(k),f=[],g=0;g<k;++g)for(e[g]=F.node_object(g,{circle:"A",name:i+F.node_name(g)}),h=0;h<g;++h)f.push(F.edge_object(j,g,h,{notLayout:!0,undirected:!0}));if("cliquestf"===a)for(g=0;g<k;++g)e[g+k]=F.node_object(g+k),e[g+2*k]=F.node_object(g+2*k),f.push(F.edge_object(j,g,g+k,{undirected:!0})),f.push(F.edge_object(j,g,g+2*k,{undirected:!0}));break;case"wheel":for(e=new Array(k),g=0;g<k;++g)e[g]=F.node_object(g,{name:i+F.node_name(g)});f=F.wheel_edges(j,_.range(k),k*l/2);var m=f[0].distance;for(g=0;g<b[1];++g)for(h=0;h<k;++h)f.push(F.edge_object(j,h,(h+1)%k,{distance:m,par:g+2}));break;default:throw new Error("unknown generation type "+a)}var n={nodes:e,links:f};d(null,n)},F.wheel_edges=function(a,b,c){for(var d=b.length,e=[],f=Math.floor(d/2),g=2*c*Math.sin(Math.PI/d),h=2*c*Math.sin(f*Math.PI/d),i=0;i<d;++i)e.push(F.edge_object(a,b[i],b[(i+1)%d],{distance:g}));for(i=0;i<d/2;++i)e.push(F.edge_object(a,b[i],b[(i+f)%d],{distance:h})),d%2&&i!=Math.floor(d/2)&&e.push(F.edge_object(a,b[i],b[(i+d-f)%d],{distance:h}));return e},F.line_breaks=function(a,b){var c=new RegExp(a,"g");return function(a){var d,e,f=a.key,g="",h=[],i=0;do d=c.exec(f),e=d?f.slice(i,c.lastIndex):f.slice(i),g.length+e.length>b&&g.length>0&&(h.push(g),g=""),g+=e,i=c.lastIndex;while(null!==d);return h.push(g),h}},F.build_type_graph=function(a,b,c,d,e,f){var g={},h={},i={};return a.forEach(function(a){g[c(a)]=a;var b=d(a);h[b]||(h[b]={type:b})}),b.forEach(function(a){var b,c,h=e(a),j=f(a);if(!(b=g[h]))throw new Error("source key "+h+" not found!");if(!(c=g[j]))throw new Error("target key "+j+" not found!");var k=d(b)+"/"+d(c);i[k]||(i[k]={type:k,source:d(b),target:d(c)})}),{nodes:Object.keys(h).map(function(a){return h[a]}),edges:Object.keys(i).map(function(a){return i[a]})}},F.d3=a,F.crossfilter=b,F.dc=c,F}if("function"==typeof define&&define.amd)define(["d3","crossfilter","dc"],a);else if("object"==typeof module&&module.exports){var b=require("d3"),c=require("crossfilter");"function"!=typeof c&&(c=c.crossfilter);var d=require("dc");module.exports=a(b,c,d)}else this.dc_graph=a(d3,crossfilter,dc)}();
//# sourceMappingURL=dc.graph.min.js.map