UNPKG

zingchart

Version:

Our JavaScript charting library is a commercial product. But the full branded version is free to try, forever.

8 lines (7 loc) 42.8 kB
/* All of the code within the ZingChart software is developed and copyrighted by ZingChart, Inc., and may not be copied, replicated, or used in any other software or application without prior permission from ZingChart. All usage must coincide with the ZingChart End User License Agreement which can be requested by email at support@zingchart.com. Build 2.9.11_ES6 */ zingchart.setModule("tree"),function(){if(!ZC.ZCVector){ZC.ZCVector=function(e,t){this.fMagnitude=e,this.fDirection=t,this.fMagnitude<0&&(this.fMagnitude=-this.fMagnitude,this.fDirection=(180+this.fDirection)%360),this.fDirection<0&&(this.fDirection=360+this.fDirection)},ZC.ZCVector.add=function(e,t){var i=e.fMagnitude*Math.cos(Math.PI/180*e.fDirection),n=e.fMagnitude*Math.sin(Math.PI/180*e.fDirection);i+=t.fMagnitude*Math.cos(Math.PI/180*t.fDirection),n+=t.fMagnitude*Math.sin(Math.PI/180*t.fDirection);var r,a=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));return r=0===a?0:180/Math.PI*Math.atan2(n,i),new ZC.ZCVector(a,r)},ZC.ZCVector.sub=function(e,t){var i=e.fMagnitude*Math.cos(Math.PI/180*e.fDirection),n=e.fMagnitude*Math.sin(Math.PI/180*e.fDirection);i-=t.fMagnitude*Math.cos(Math.PI/180*t.fDirection),n-=t.fMagnitude*Math.sin(Math.PI/180*t.fDirection);var r,a=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));return r=0===a?0:180/Math.PI*Math.atan2(n,i),new ZC.ZCVector(a,r)},ZC.ZCVector.multiply=function(e,t){return new ZC.ZCVector(e.fMagnitude*t,e.fDirection)},ZC.ZCVector.prototype.toXY=function(){return[this.fMagnitude*Math.cos(Math.PI/180*this.fDirection),this.fMagnitude*Math.sin(Math.PI/180*this.fDirection)]};var e=function(e,t){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(Math.pow(i,2)+Math.pow(n,2))},t=function(e,t){var i=e.x+(t.x-e.x)/2,n=e.y+(t.y-e.y)/2,r=i-e.x,a=n-e.y;return 0===r&&0===a?0:0===r?a>=0?90:270:0===a?r>=0?0:180:Math.atan2(a,r)*(180/Math.PI)},i=function(i,n,r,a,l){var c=Math.max(e(n,r),1),d=Math.min(.99,i*(l||1))*(c-a);d=Math.max(d,-a),d=Math.min(d,a);var o=t(n,r);return new ZC.ZCVector(d,o)},n=function(i,n,r,a,l,c,d,o){var h=Math.max(e(n,r),1),s=n.size||1,g=r.size||1;if(d||(s=g=1),o&&(c=1),h>c*a)return new ZC.ZCVector(0,0);var _=-i*s*g/(h*h*l);_=Math.max(_,-a),_=Math.min(_,a);var p=t(n,r);return new ZC.ZCVector(_,p)},r=function(e){for(var t=zingchart.plugins.tree[e].data,i=Number.MAX_VALUE,n=-Number.MAX_VALUE,r=Number.MAX_VALUE,a=-Number.MAX_VALUE,l=0;l<t.length;l++)"link"===t[l].type?(r=Math.min(r,t[l][ZC._[9]]),a=Math.max(a,t[l][ZC._[9]])):(i=Math.min(i,t[l][ZC._[9]]),n=Math.max(n,t[l][ZC._[9]]));zingchart.plugins.tree[e].minValue=i,zingchart.plugins.tree[e].maxValue=n,zingchart.plugins.tree[e].minLinkValue=r,zingchart.plugins.tree[e].maxLinkValue=a};zingchart.plugins.tree=zingchart.plugins.tree||{},zingchart.plugins.tree.graph_defaults={plotarea:{margin:5},container:{padding:5},node:{type:"circle","border-width":1,"border-color":"#fff",tooltip:{text:"%text"},label:{"font-size":10,padding:1,color:"#000",text:"%text"}},link:{flat:!0,"line-color":"#999",alpha:.5,type:"line"}},zingchart.plugins.tree.orgchart_defaults={plotarea:{margin:10},container:{"tree-right":{padding:"20 60 20 60"},"tree-left":{padding:"20 60 20 60"},"tree-down":{padding:"20 60 20 60"},"tree-up":{padding:"20 60 20 60"}},node:{type:"rectangle",width:80,height:30,"border-width":1,"border-color":"#333","background-color":"#fff",label:{color:"#000",width:80,"font-size":10,align:"center",anchor:"c",text:"%text"}},link:{aspect:"split","line-color":"#999","line-width":1}},zingchart.plugins.tree.tree_defaults={plotarea:{margin:10},container:{"tree-radial":{padding:"120 120 120 120"},"tree-right":{padding:"20 120 20 40"},"tree-left":{padding:"20 40 20 120"},"tree-down":{padding:"40 20 120 20"},"tree-up":{padding:"120 20 40 20"}},link:{aspect:"arc","line-color":"#999","line-width":1},"node[collapsed]":{"border-width":1,"border-color":"#666"},node:{type:"circle",tooltip:{text:"%text:%value"},label:{"font-size":10,padding:1,width:100,color:"#000","clip-text":!0,text:"%text"},label_jsRule:function(e,t,i){var n={},r=ZC._i_(t.label.width)/2,a=null!==ZC._n_(t.width)?ZC._i_(t.width)/2:t.size,l=null!==ZC._n_(t.height)?ZC._i_(t.height)/2:t.size,c=Math.max(a,l);switch(i){case"tree-right":0===e.level?n["offset-y"]=-t.size-l:(n.anchor=e.children&&e.children.length?"r":"l",n["offset-x"]=e.children&&e.children.length?-5-a:5+a,n.align=e.children&&e.children.length?"right":"left");break;case"tree-left":0===e.level?n["offset-y"]=-t.size-l:(n.anchor=e.children&&e.children.length?"l":"r",n["offset-x"]=e.children&&e.children.length?5+a:-5-a,n.align=e.children&&e.children.length?"left":"right");break;case"tree-down":n.anchor="c",0===e.level?n["offset-y"]=-t.size-l:(n["offset-y"]=e.children&&e.children.length?-5-r-l:5+r+l,n.angle=91,n.align=e.children&&e.children.length?"right":"left",n["offset-x"]=e.children&&e.children.length?1:0);break;case"tree-up":n.anchor="c",0===e.level?n["offset-y"]=t.size+l:(n["offset-y"]=e.children&&e.children.length?5+r+l:-5-r-l,n.angle=271,n.align=e.children&&e.children.length?"right":"left",n["offset-x"]=e.children&&e.children.length?-1:0);break;case"tree-radial":var d,o;0===e.level?n["offset-y"]=-t.size-l:(e.children&&e.children.length?(e.angle>90&&e.angle<270?(n.angle=e.angle+180,n.align="left"):(n.angle=e.angle,n.align="right"),d=ZC.AP.BN(e.cx,e.cy,e.radius,e.angle),o=ZC.AP.BN(e.cx,e.cy,e.radius-(5+r+c),e.angle)):(e.angle>90&&e.angle<270?(n.angle=e.angle+180,n.align="right"):(n.angle=e.angle,n.align="left"),d=ZC.AP.BN(e.cx,e.cy,e.radius,e.angle),o=ZC.AP.BN(e.cx,e.cy,e.radius+(5+r+c),e.angle)),n["offset-x"]=o[0]-d[0],n["offset-y"]=o[1]-d[1])}for(var h in n)null!==ZC._n_(t.label[h])&&delete n[h];return n}}},zingchart.bind(null,"dataparse",function(e,t){for(var i,n,r,a,l=0,c=t[ZC._[16]].length;l<c;l++)if(t[ZC._[16]][l].type&&"tree"===t[ZC._[16]][l].type){var d=t[ZC._[16]][l].type;t[ZC._[16]][l]["plugin-type"]=d;var o=t[ZC._[16]][l];zingchart.normalize(o),o.type="null";var h={};o.options&&(h=o.options[d]||o.options),ZC._todash_(h),o[ZC._[11]]=o[ZC._[11]]||[];var s=h["text-attr"]||"text",g=h["value-attr"]||ZC._[9],_=h["source-attr"]||"source",p=h["target-attr"]||"target",u=h.aspect||"tree-right",f=ZC._b_(ZC._c_(h["org-chart"],0));if(o.plotarea=o.plotarea||{},f?ZC._inj_(o.plotarea,zingchart.plugins.tree.orgchart_defaults.plotarea||{}):"graph"===u?ZC._inj_(o.plotarea,zingchart.plugins.tree.graph_defaults.plotarea||{}):ZC._inj_(o.plotarea,zingchart.plugins.tree.tree_defaults.plotarea||{}),!(o[ZC._[11]]instanceof Array)){var Z=[],C={},v=function(e,t){var i=(e.text||e.name||e[s]).toLowerCase().replace(/[^a-z0-9_]+/gi,"");C[i]?i+=C[i]++:C[i]=1;var n={id:i,text:e.text||e.name||e[s]||i,value:e[ZC._[9]]||e[ZC._[21]]||e[g],parent:t||""};if(Z.push(n),e.children)for(var r=0;r<e.children.length;r++)v(e.children[r],i)};v(o[ZC._[11]]),o[ZC._[11]]=Z}for(i=0;i<o[ZC._[11]].length;i++)o[ZC._[11]][i].text=o[ZC._[11]][i].text||o[ZC._[11]][i].name||o[ZC._[11]][i][s]||"Node "+i,o[ZC._[11]][i][ZC._[9]]=o[ZC._[11]][i][ZC._[9]]||o[ZC._[11]][i][ZC._[21]]||o[ZC._[11]][i][g],o[ZC._[11]][i]["node-value"]=o[ZC._[11]][i][ZC._[9]],o[ZC._[11]][i].id||(o[ZC._[11]][i].text?o[ZC._[11]][i].id=o[ZC._[11]][i].text.toLowerCase().replace(/[^a-z0-9_]+/gi,""):o[ZC._[11]][i].id="node"+i),o[ZC._[11]][i].group=o[ZC._[11]][i].group||-1,"graph"!==u?(o[ZC._[11]][i].collapsed=!1,o[ZC._[11]][i].visible=!0):(o[ZC._[11]][i].text=o[ZC._[11]][i].text||o[ZC._[11]][i].name||o[ZC._[11]][i][s]||"Node "+i,(o[ZC._[11]][i].source||o[ZC._[11]][i].from||o[ZC._[11]][i][_])&&(o[ZC._[11]][i].target||o[ZC._[11]][i].to||o[ZC._[11]][i][p])?(o[ZC._[11]][i].source=o[ZC._[11]][i].source||o[ZC._[11]][i].from||o[ZC._[11]][i][_],o[ZC._[11]][i].target=o[ZC._[11]][i].target||o[ZC._[11]][i].to||o[ZC._[11]][i][p],o[ZC._[11]][i].type="link"):o[ZC._[11]][i].type="node"),"graph"===u&&o[ZC._[11]][i].parent&&""!==o[ZC._[11]][i].parent&&o[ZC._[11]].push({type:"link",source:o[ZC._[11]][i].id,target:o[ZC._[11]][i].parent,value:1});for(zingchart.plugins.tree[e.id]=zingchart.plugins.tree[e.id]||{},zingchart.plugins.tree[e.id].size=o[ZC._[11]].length,i=0;i<o[ZC._[11]].length;i++)if(o[ZC._[11]][i].idx=i,null!==ZC._n_(o[ZC._[11]][i].parent))for(n=0;n<o[ZC._[11]].length;n++)o[ZC._[11]][n].id===o[ZC._[11]][i].parent&&(o[ZC._[11]][i].pidx=n,o[ZC._[11]][n].children=o[ZC._[11]][n].children||[],o[ZC._[11]][n].children.push(i));else o[ZC._[11]][i].parent="";for(var x=!0,z=[];x;)for(x=!1,i=0;i<o[ZC._[11]].length;i++)if(null!==ZC._n_(o[ZC._[11]][i].parent)&&(r=o[ZC._[11]][i].parent,-1===ZC.AV(z,r))){var m=0,b=!0;for(a=-1,n=0;n<o[ZC._[11]].length;n++)o[ZC._[11]][n].id===r&&(a=n,o[ZC._[11]][i].pidx=n),null!==ZC._n_(o[ZC._[11]][n].parent)&&o[ZC._[11]][n].parent===r&&(null!==ZC._n_(o[ZC._[11]][n][ZC._[9]])&&ZC._f_(o[ZC._[11]][n][ZC._[9]])+""==o[ZC._[11]][n][ZC._[9]]+""?m+=ZC._f_(o[ZC._[11]][n][ZC._[9]]):b=!1);if(b&&-1!==a){null!==ZC._n_(o[ZC._[11]][a][ZC._[9]])&&(o[ZC._[11]][a]["node-value"]=o[ZC._[11]][a][ZC._[9]]),o[ZC._[11]][a][ZC._[9]]=m,z.push(r),x=!0;continue}}for(i=0;i<o[ZC._[11]].length;i++)o[ZC._[11]][i][ZC._[9]]=o[ZC._[11]][i][ZC._[9]]||1,"graph"===u&&(o[ZC._[11]][i].container=o[ZC._[11]][i].container||0);for(var y=!0,M=Number.MAX_VALUE,w=-Number.MAX_VALUE,k=0;y;)for(y=!1,i=0;i<o[ZC._[11]].length;i++)"graph"===u&&"node"!==o[ZC._[11]][i].type||(M=Math.min(M,o[ZC._[11]][i][ZC._[9]]),w=Math.max(w,o[ZC._[11]][i][ZC._[9]])),null===ZC._n_(o[ZC._[11]][i].level)?o[ZC._[11]][i].sibling||null!==ZC._n_(o[ZC._[11]][i].parent)&&""!==o[ZC._[11]][i].parent?(a=o[ZC._[11]][i].pidx,null!==ZC._n_(a)?null===ZC._n_(o[ZC._[11]][a].level)?y=!0:(o[ZC._[11]][i].level=ZC._i_(o[ZC._[11]][a].level)+1,"graph"!==u&&(o[ZC._[11]][i].container=o[ZC._[11]][a].container)):o[ZC._[11]][i].container=o[ZC._[11]][i].level=0):(o[ZC._[11]][i].level=0,"graph"!==u&&(o[ZC._[11]][i].container=k),k++):(a=o[ZC._[11]][i].pidx,null!==ZC._n_(a)?o[ZC._[11]][i].container=o[ZC._[11]][a].container||0:o[ZC._[11]][i].container=0);if(zingchart.plugins.tree[e.id].minValue=M,zingchart.plugins.tree[e.id].maxValue=w,"graph"===u){var V=Number.MAX_VALUE,A=-Number.MAX_VALUE;for(i=0;i<o[ZC._[11]].length;i++)"link"===o[ZC._[11]][i].type&&(V=Math.min(V,o[ZC._[11]][i][ZC._[9]]),A=Math.max(A,o[ZC._[11]][i][ZC._[9]]));zingchart.plugins.tree[e.id].minLinkValue=V,zingchart.plugins.tree[e.id].maxLinkValue=A}o.plotarea=o.plotarea||{},ZC._inj_(o.plotarea,{margin:"10 10 10 10","mask-tolerance":[0,0]})}return t});var a=function(r){var a=zingchart.getLoader(r.loader.id),c=zingchart.getGraph(a,r.graphid),d=c.o;if("tree"===d["plugin-type"]){var o,g,_,p=zingchart.getGraphInfo(a,d,c.L).plotarea,u={};d.options&&(u=d.options.tree||d.options),ZC._todash_(u);var f=u.palette||["#a7da47","#00b0e1","#ef4810","#f9c332","#84680a","#4d62b1","#00BAF2","#E80C60","#E2D51A","#9B26AF","#FB301E","#00AE4D","#20398B"],Z=u.aspect||"tree-right",C=ZC._b_(ZC._c_(u["org-chart"],0)),v=u.layout||"x",x=ZC._i_(ZC._c_(u.progression,"0")),z=ZC._i_(ZC._c_(u.aperture,"360")),m=ZC._i_(ZC._c_(u["ref-angle"],"0")),b=ZC._i_(ZC._c_(u["min-size"],4)),y=ZC._i_(ZC._c_(u["max-size"],4)),M=ZC._i_(ZC._c_(u["min-link-width"],1)),w=ZC._i_(ZC._c_(u["max-link-width"],5)),k=ZC._f_(ZC._c_(u["attraction-constant"],.99)),V=ZC._i_(ZC._c_(u["repulsion-constant"],1e3)),A=ZC._i_(ZC._c_(u["repulsion-distance-factor"],20)),N=ZC._f_(ZC._c_(u["spring-length"],40)),L=ZC._i_(ZC._c_(u["max-iterations"],1e3)),X=ZC._f_(ZC._c_(u["damping-step"],.005)),P=ZC._b_(ZC._c_(u["weighted-nodes"],0)),E=ZC._b_(ZC._c_(u["weighted-links"],0)),I=Math.max(1,ZC._i_(ZC._c_(u["packing-factor"],1))),R=Math.max(.1,ZC._f_(ZC._c_(u["depth-ratio"],2))),j=ZC._b_(ZC._c_(u["weighted-links"],0));C&&(j=!0),zingchart.plugins.tree[r.id].data=[].concat(d[ZC._[11]]||[]),zingchart.plugins.tree[r.id].attractionConstant=k,zingchart.plugins.tree[r.id].repulsionConstant=V,zingchart.plugins.tree[r.id].springLength=N;var D,Y,S=function(e,t){var i=zingchart.plugins.tree[r.id].data;if(i[e].children)for(var n=0;n<i[e].children.length;n++)i[i[e].children[n]].coord+=t,S(i[e].children[n],t)},U=function(e){var t=zingchart.plugins.tree[r.id].data,i=!1,n=-1,a=-1;if(null===ZC._n_(t[e].pidx))i=!0;else{var l=ZC.AV(t[t[e].pidx].children,e);0===l?i=!0:(i=!1,n=l-1,a=t[t[e].pidx].children[n])}return{first:i,prevSiblingIndex:n,prevIndex:a}},F=function(e,t){var i=zingchart.plugins.tree[r.id].data,n=[];if(n.push(e),i[e].children&&i[e].children.length&&(t||!i[e].collapsed))for(var a=0;a<i[e].children.length;a++)n=n.concat(F(i[e].children[a]));return n},B=function(e){for(var t=zingchart.plugins.tree[r.id].data,i=Number.MAX_VALUE,n=0;n<e.length;n++)i=Math.min(i,t[e[n]].coord);return i},q=function(e){for(var t=zingchart.plugins.tree[r.id].data,i=-Number.MAX_VALUE,n=0;n<e.length;n++)i=Math.max(i,t[e[n]].coord);return i},T=null,O=function(){var e,t=zingchart.plugins.tree[r.id].data;if(!T)for(T={},e=0;e<t.length;e++)T[t[e].id]=t[e].idx;var i={};for(e=0;e<t.length;e++){if(t[e].reference){var n=t[T[t[e].reference]];i[t[e].reference]=i[t[e].reference]||1,t[e].coord=n.coord,t[e].level=n.level+i[t[e].reference],i[t[e].reference]+=1}if(t[e].sibling&&0===t[e].level){var a=t[T[t[e].sibling]];t[e].idx<a.idx?t[e].coord=a.coord-I:t[e].coord=a.coord+I}}G()},W=0,G=function(){for(var e=zingchart.plugins.tree[r.id].data,t=0;t<e.length;t++)e[t].visible&&(W=Math.max(W,d[ZC._[11]][t].level))},J=function(e,t){var i=zingchart.plugins.tree[r.id].data;if(i[e].visible&&(i[e].reference?i[e].coord=0:i[e].coord=t*I,i[e].children))for(var n=0;n<i[e].children.length;n++)J(i[e].children[n],n*I)},K=function(e){var t=zingchart.plugins.tree[r.id].data;if(t[e].visible&&!t[e].reference&&t[e].children&&!t[e].collapsed){var i=t[e].children.length,n=t[e].children[0],a=t[e].children[i-1],l=(t[n].coord+t[a].coord)/2,c=U(e),d=c.first,o=c.prevSiblingIndex;if(d)t[e].coord=l;else{var h=t[t[e].pidx].children[o];t[e].coord=t[h].coord+I;var s=t[e].coord-l;0!==s&&S(e,s)}}},Q=function(e){var t=zingchart.plugins.tree[r.id].data;if(t[e].visible&&!t[e].reference){var i=U(e),n=i.first,a=i.prevIndex;if(!n){var l=function(e,t,i){var n=zingchart.plugins.tree[r.id].data,a=[];if(t){for(;n[e].children&&n[e].children.length&&!n[e].collapsed&&!n[e].fake;)e=n[e].children[n[e].children.length-1];for(;null!==ZC._n_(n[e].pidx);)(-1===i||n[e].level<=i)&&a.push(e),e=n[e].pidx}if(a.push(e),!t)for(;n[e].children&&n[e].children.length&&!n[e].collapsed&&!n[e].fake;)e=n[e].children[n[e].children.length-1],(-1===i||n[e].level<=i)&&a.push(e);return a}(a,!1,-1),c=function(e,t,i){var n=zingchart.plugins.tree[r.id].data,a=[];if(t){for(;n[e].children&&n[e].children.length&&!n[e].collapsed&&!n[e].fake;)e=n[e].children[0];for(;null!==ZC._n_(n[e].pidx);)(-1===i||n[e].level<=i)&&a.push(e),e=n[e].pidx}if(a.push(e),!t)for(;n[e].children&&n[e].children.length&&!n[e].collapsed&&!n[e].fake;)e=n[e].children[0],(-1===i||n[e].level<=i)&&a.push(e);return a}(e,!1,-1),d=q(l),o=B(c),h=0;o<=d&&(h=d-o+I,t[e].coord+=h,S(e,h))}if(t[e].children&&t[e].children.length&&!t[e].collapsed)for(var s=0;s<t[e].children.length;s++)Q(t[e].children[s])}},H=function(e){var t=zingchart.plugins.tree[r.id].data;if(t[e].visible&&t[e].children&&!t[e].collapsed){for(var i=t[e].children.length,n=t[e].children[0],a=t[e].children[i-1],l=(t[n].coord+t[a].coord)/2,c=t[e].coord-l,d=0;d<t.length;d++)t[d].sibling===t[e].id&&(t[d].coord-=c);t[e].coord=l}},$=function(e){var t=zingchart.plugins.tree[r.id].data,i=0;if(!t[e].visible)return i;if(t[e].children&&t[e].children.length>1&&!t[e].collapsed)for(var n=1;n<t[e].children.length;n++){var a=t[t[e].children[n]],l=t[t[e].children[n-1]];i+=ee(l,a)}return i},ee=function(e,t){var i=0,n="r";return e.children&&e.children.length?t.children&&t.children.length||(n="l",t.coord-e.coord>I&&(t.coord=e.coord+I,i++)):t.children&&t.children.length?(n="r",t.coord-e.coord>I&&(e.coord=t.coord-I,i++)):t.coord-e.coord>I&&("r"===n?(e.coord=t.coord-I,i++):(t.coord=e.coord+I,i++)),i},te=function(e){var t=zingchart.plugins.tree[r.id].data,i=U(e),n=i.first,a=i.prevIndex;if(!n){var l=F(a),c=F(e),d=q(l),o=B(c),h=0;o>d+I&&(h=o-d-I,t[e].coord+=-h,S(e,-h))}},ie=[],ne=[],re=[],ae=[],le=[],ce=[],de={},oe={},he={},se=1,ge=0,_e="",pe=[0,0],ue=!1,fe={},Ze=!0,Ce=!0,ve=zingchart.getInstance(c,"textbox");C?ve.append(zingchart.plugins.tree.orgchart_defaults.container[Z]):"graph"===Z?ve.append(zingchart.plugins.tree.graph_defaults.container):ve.append(zingchart.plugins.tree.tree_defaults.container[Z]),ve.append(u.container),ve.parse();var xe=ve.FO,ze=ve.FP,me=ve.FX,be=ve.EP,ye=function(e){if(ie=[],e>1){var t=-1,i=-1;if("h"===v)t=1,i=e;else if("v"===v)t=e,i=1;else if(-1!==v.indexOf("x")){var n=v.split("x");""!==n[0]&&(t=ZC._i_(n[0])),""!==n[1]&&(i=ZC._i_(n[1])),-1===t&&-1===i?t=i=Math.ceil(Math.sqrt(e)):-1===t&&-1!==i?t=Math.ceil(e/i):-1!==t&&-1===i&&(i=Math.ceil(e/t))}for(var r=p.width/i,a=p.height/t,l=0;l<t;l++)for(var c=0;c<i;c++)ie[l*i+c]={x:p.x+c*r,y:p.y+l*a,width:r,height:a}}else ie[0]={x:p.x,y:p.y,width:p.width,height:p.height}};zingchart.plugins.tree[r.id].bFirstRender=!0;var Me={},we=function(c){if(a.T4=[],k=zingchart.plugins.tree[r.id].attractionConstant,V=zingchart.plugins.tree[r.id].repulsionConstant,N=zingchart.plugins.tree[r.id].springLength,!c||(se=1,ge=0,!ue)){ue=!0;var d,h,g=zingchart.plugins.tree[r.id].data,_=le.length,p=ce.length,f=0,Z=0,C=[];""!==_e&&(g[de[_e]].x=pe[0],g[de[_e]].y=pe[1]);var v,x=[];for(o=0;o<_;o++)if((d=g[le[o]])&&(v=ie[d.container],x[d.container]||(x[d.container]={minX:Number.MAX_VALUE,minY:Number.MAX_VALUE,maxX:-Number.MAX_VALUE,maxY:-Number.MAX_VALUE}),d.id!==_e)){var z,m={x:v.x+v.width/2,y:v.y+v.height/2},b={x:v.x+v.width/2,y:v.y+v.height/2},y=N,I=1,R="";null!==ZC._n_(d.level)&&d.level>0&&y>20&&(y=Math.round(Math.max(20,y-5*d.level)));var j=new ZC.ZCVector(e(m,d),t(m,d)),D=new ZC.ZCVector(0,0),Y=new ZC.ZCVector(0,0);for(h=0;h<_;h++)if(o!==h&&d.container===g[le[h]].container){I=1,z=y,R=d.id+"-"+g[le[h]].id,ke[R]&&(z=ke[R]),E&&g[he[R]]&&zingchart.plugins.tree[r.id].maxLinkValue!==zingchart.plugins.tree[r.id].minLinkValue&&(I+=Math.round((w-M)*(g[he[R]].value-zingchart.plugins.tree[r.id].minLinkValue)/(zingchart.plugins.tree[r.id].maxLinkValue-zingchart.plugins.tree[r.id].minLinkValue)));var S=n(V,d,g[le[h]],z,I,A,P,g[he[R]]?1:0);Y=ZC.ZCVector.add(Y,S)}if(d.level){var U=n(V,d,b,y,I,10*A,P,0);Y=ZC.ZCVector.add(Y,U)}D=ZC.ZCVector.add(D,Y);var F=!1,B=new ZC.ZCVector(0,0);if(oe[d.id])for(h=0;h<oe[d.id].length;h++){I=1,z=y,R=d.id+"-"+g[de[oe[d.id][h]]].id,ke[R]&&(z=ke[R]),E&&(I=M,zingchart.plugins.tree[r.id].maxLinkValue!==zingchart.plugins.tree[r.id].minLinkValue&&(I+=Math.round((w-M)*(g[he[R]].value-zingchart.plugins.tree[r.id].minLinkValue)/(zingchart.plugins.tree[r.id].maxLinkValue-zingchart.plugins.tree[r.id].minLinkValue))));var q=i(k,d,g[de[oe[d.id][h]]],z,I);q.fMagnitude/=2,B=ZC.ZCVector.add(B,q),g[de[oe[d.id][h]]].id===_e&&(F=!0)}else{var T=i(k,d,b,y,1);B=ZC.ZCVector.add(B,T)}if(oe[d.id]?(B.fMagnitude>y/10||oe[d.id].length>1)&&(B=ZC.ZCVector.multiply(B,Math.min(1,(F?2.5:1)/oe[d.id].length))):B.fMagnitude=Math.min(5*(F?2.5:1),B.fMagnitude),d.cg){var O=i(999*k,d,d.cg,5,1);B=ZC.ZCVector.add(B,O)}D=ZC.ZCVector.add(D,B),D=ZC.ZCVector.multiply(D,se);var W=(j=ZC.ZCVector.add(j,D)).toXY(),G=e(d,{x:v.x+v.width/2+W[0],y:v.y+v.height/2+W[1]});f+=G,Z=Math.max(Z,G),d.__x=v.x+v.width/2+W[0],d.__y=v.y+v.height/2+W[1]}for(o=0;o<_;o++)(d=g[le[o]]).id!==_e&&(d.x=d.__x,d.y=d.__y),x[d.container].minX=Math.min(x[d.container].minX,d.x),x[d.container].maxX=Math.max(x[d.container].maxX,d.x),x[d.container].minY=Math.min(x[d.container].minY,d.y),x[d.container].maxY=Math.max(x[d.container].maxY,d.y);var J=0,K=[];for(o=0;o<x.length;o++)K[o]=1,x[o].maxX-x[o].minX>ie[o].width&&(K[o]=Math.min(K[o],ie[o].width/(x[o].maxX-x[o].minX))),x[o].maxY-x[o].minY>ie[o].height&&(K[o]=Math.min(K[o],ie[o].height/(x[o].maxY-x[o].minY))),x[o].diffX=ie[o].x+ie[o].width/2-(x[o].maxX+x[o].minX)/2,x[o].diffY=ie[o].y+ie[o].height/2-(x[o].maxY+x[o].minY)/2,J+=e({x:ie[o].x+ie[o].width/2,y:ie[o].y+ie[o].height/2},{x:(x[o].maxX+x[o].minX)/2,y:(x[o].maxY+x[o].minY)/2});var Q={};for(o=0;o<_;o++)(d=g[le[o]]).cg||(""===_e?(d.x+=x[d.container].diffX/N,d.y+=x[d.container].diffY/N):g[de[_e]].container!==d.container&&(d.x+=x[d.container].diffX/N,d.y+=x[d.container].diffY/N)),Me[d.id]&&(d.x=Me[d.id][0]||d.x,d.y=Me[d.id][1]||d.y),1!==K[d.container]?(d._x_=ie[d.container].x+ie[d.container].width/2+(d.x-ie[d.container].x-ie[d.container].width/2)*K[d.container],d._y_=ie[d.container].y+ie[d.container].height/2+(d.y-ie[d.container].y-ie[d.container].height/2)*K[d.container]):(d._x_=d.x,d._y_=d.y),d._x_=Math.max(ie[d.container].x,Math.min(ie[d.container].x+ie[d.container].width,d._x_)),d._y_=Math.max(ie[d.container].y,Math.min(ie[d.container].y+ie[d.container].height,d._y_)),d._x_>0&&d._x_<1&&(d._x_=1.1),d._y_>0&&d._y_<1&&(d._y_=1.1),fe[d.id]=[d._x_,d._y_],Q={id:"node_"+d.id,x:d._x_,y:d._y_},ge>=15&&(Q.visible=Ze),C.push(Q);for(o=0;o<p;o++)if(d=g[ce[o]]){var H=g[de[d.source]],$=g[de[d.target]];Q={id:"link_"+H.id+"_"+$.id,points:[[H._x_,H._y_],[$._x_,$._y_]]},ZC._cp_(u.link,Q),ge>=15&&(Q.visible=Ce),s(Q,H.cls?u["node[cls-"+H.cls+"]"]:u.node,$.cls?u["node[cls-"+$.cls+"]"]:u.node),C.push(Q)}zingchart.exec(r.id,"updateobject",{type:"shape",data:C.concat(l(C))}),++ge<15||ge<L&&(f>1&&Z>.1||J>2)?(se=Math.max(.001,se-X),window.setTimeout(we,1)):ue=!1}},ke={},Ve=zingchart.plugins.tree[r.id]._render_graph_=function(){zingchart.exec(r.id,"removeobject",{type:"shape",cls:"zctreeshape"}),re=[],ae=[],le=[],ce=[],de={},oe={},he={};var e,t=zingchart.plugins.tree[r.id].data,i=!1,n=[],a=0;for(o=0;o<t.length;o++)((e=t[o]).parent||e.children)&&(i=!0),"node"===e.type?(le.push(o),de[e.id]=o,n[e.container]||(n[e.container]=[],a++),n[e.container].push(o)):(ce.push(o),oe[e.source]=oe[e.source]||[],oe[e.source].push(e.target),oe[e.target]=oe[e.target]||[],oe[e.target].push(e.source),he[e.source+"-"+e.target]=o,he[e.target+"-"+e.source]=o);ye(a);for(var c={},d=0;d<ie.length;d++){var h=ie[d];if(n[d]=n[d]||[],n[d].length){var g=[h.x+h.width/2,h.y+h.height/2];if(i)for(var _={},p=0;p<n[d].length;p++)if((e=t[n[d][p]]).parent){var Z=t[de[e.parent]];if(Z){var C=c[Z.id],v=ZC.AP.BN(C[0],C[1],Math.max(25,60-5*Z.level),_[e.parent]);c[e.id]=[v[0],v[1]];var x=15;e.level<=1&&(x=360/Math.max(1,(Z.children||[]).length)),_[e.id]||(_[e.id]=_[Z.id],e.children&&Z.children.length>1&&(_[e.id]-=15*(e.children.length-1)/2)),_[Z.id]+=x}}else c[e.id]=[g[0],g[1]],_[e.id]=1;else for(var z=Math.ceil(Math.sqrt(n[d].length)),m=Math.min(10,Math.round(h.width/z)),k=m*z,V=Math.min(10,Math.round(h.height/z)),A=V*z,N=0;N<z;N++)for(var L=0;L<z;L++){var X=N*z+L;X<n[d].length&&(c[t[n[d][X]].id]=[g[0]-k/2+L*m,g[1]-A/2+N*V])}}}for(o=0;o<le.length;o++){e=t[le[o]],fe[e.id]?(e.x=fe[e.id][0],e.y=fe[e.id][1]):(e.x=c[e.id][0],e.y=c[e.id][1]);var P=b;zingchart.plugins.tree[r.id].maxValue!==zingchart.plugins.tree[r.id].minValue&&(P+=Math.round((y-b)*(e.value-zingchart.plugins.tree[r.id].minValue)/(zingchart.plugins.tree[r.id].maxValue-zingchart.plugins.tree[r.id].minValue))),e.size=1+.5*P/y;var E,I=ZC._i_(-1!==e.group?e.group:e.level||"0"),R={};if(ZC._cp_(zingchart.plugins.tree.graph_defaults.node,R),ZC._cp_({id:"node_"+e.id,cls:"zctreeshape","background-color":f[I%f.length],size:P},R),ZC._cp_(u.node||{},R),ZC._cp_(u["node[group-"+e.group+"]"],R),ZC._cp_(u["node[container-"+e.container+"]"],R),e.cls)for(var j=e.cls.split(/\s/),D=0;D<j.length;D++)ZC._cp_(u["node[cls-"+j[D]+"]"],R);if(u.nodes&&u.nodes[e.id]&&ZC._cp_(u.nodes[e.id],R),R["js-rule"])try{var Y=ZC.execFn(R["js-rule"].replace("javascript:","").replace("()",""),window,r.id,e,R);Y&&ZC._cp_(Y,R)}catch(O){}e.style&&ZC._cp_(e.style,R);var S={decimals:null,short:!1,"thousands-separator":",","decimals-separator":"."};if(ZC._cp_(R,S),R.label&&R.label.text){for(E in R.label.text=R.label.text.replace(/%text/gi,e.text).replace(/%node-value/gi,zingchart.formatNumber(e["node-value"],S)).replace(/%value/gi,zingchart.formatNumber(e.value,S)),e)"data-"===E.substring(0,5)&&(R.label.text=R.label.text.replace(new RegExp("%"+E,"g"),e[E]));R.label.text=R.label.text.replace(new RegExp("%data-([a-zA-Z0-9]+)","g"),"")}if(R.tooltip&&R.tooltip.text){for(E in ZC._cp_(R.tooltip,S),R.tooltip.text=R.tooltip.text.replace(/%text/gi,e.text).replace(/%node-value/gi,zingchart.formatNumber(e["node-value"],S)).replace(/%value/gi,zingchart.formatNumber(e.value,S)),e)"data-"===E.substring(0,5)&&(R.tooltip.text=R.tooltip.text.replace(new RegExp("%"+E,"g"),e[E]));R.tooltip.text=R.tooltip.text.replace(new RegExp("%data-([a-zA-Z0-9]+)","g"),"")}zingchart.plugins.tree[r.id].bFirstRender&&(null===ZC._n_(R.visible)||R.visible||(Ze=!1),R.visible=!1),null!==ZC._n_(R.x)||null!==ZC._n_(R.y)?(Me[e.id]=[0,0],null!==ZC._n_(R.x)?(R.x=ZC._i_(R.x),Me[e.id][0]=R.x):R.x=e.x,null!==ZC._n_(R.y)?(R.y=ZC._i_(R.y),Me[e.id][1]=R.y):R.y=e.y):(R.x=e.x,R.y=e.y),re.push(R)}for(o=0;o<ce.length;o++){e=t[ce[o]];var U=t[de[e.source]],F=t[de[e.target]],B=M;zingchart.plugins.tree[r.id].maxLinkValue!==zingchart.plugins.tree[r.id].minLinkValue&&(B+=Math.round((w-M)*(e.value-zingchart.plugins.tree[r.id].minLinkValue)/(zingchart.plugins.tree[r.id].maxLinkValue-zingchart.plugins.tree[r.id].minLinkValue)));var q={};if(ZC._cp_(zingchart.plugins.tree.graph_defaults.link,q),ZC._cp_({id:"link_"+U.id+"_"+F.id,cls:"zctreeshape","fast-vector-path":!0,"line-width":B,points:[[U.x,U.y],[F.x,F.y]]},q),ZC._cp_(u.link||{},q),ZC._cp_(u["link[group-"+U.group+"]"],q),ZC._cp_(u["link[container-"+U.container+"]"],q),ZC._cp_(u["link[source-"+U.id+"]"],q),ZC._cp_(u["link[target-"+F.id+"]"],q),e.cls&&ZC._cp_(u["link[cls-"+e.cls+"]"],q),q["js-rule"])try{var T=ZC.execFn(q["js-rule"].replace("javascript:","").replace("()",""),window,r.id,e,U,F,q);T&&ZC._cp_(T,q)}catch(O){}u.links&&u.links[U.id+"-"+F.id]&&ZC._cp_(u.links[U.id+"_"+F.id],q),zingchart.plugins.tree[r.id].bFirstRender&&(null===ZC._n_(q.visible)||q.visible||(Ce=!1),q.visible=!1),q.length&&(ke[U.id+"-"+F.id]=ke[F.id+"-"+U.id]=q.length),s(q,U.cls?u["node[cls-"+U.cls+"]"]:u.node,F.cls?u["node[cls-"+F.cls+"]"]:u.node),ae.push(q)}zingchart.exec(r.id,"addobject",{type:"shape",data:ae.concat(l(ae)).concat(re)}),zingchart.plugins.tree[r.id].bFirstRender=!1,window.setTimeout(function(){we(!0)},1)},Ae=function(){a.T4=[],ie=[],ne=[],re=[],ae=[];var e=zingchart.plugins.tree[r.id].data,t=[],i=[];for(o=0;o<e.length;o++)0!==e[o].level||e[o].sibling||(t.push(e[o]),i.push(o));G();var n,c,d,s={};for(o=0;o<e.length;o++)s[e[o].container+"-"+e[o].level]=s[e[o].container+"-"+e[o].level]||[],s[e[o].container+"-"+e[o].level].push(e[o].idx);ye(t.length);for(var p=0;p<ie.length;p++)if(t[p]){for(o=0;o<i.length;o++)o===p&&J(i[o],o);for(O(),g=W;g>=0;g--)if(s[p+"-"+g])for(o=0;o<s[p+"-"+g].length;o++)K(s[p+"-"+g][o]);for(O(),o=0;o<i.length;o++)Q(i[o]);for(O(),g=W-1;g>=0;g--)if(s[p+"-"+g])for(o=0;o<s[p+"-"+g].length;o++)H(s[p+"-"+g][o]);if(O(),C){for(g=W-1;g>=0;g--)if(s[p+"-"+g])for(var v=1,M=0;v>0&&M<128;){for(v=0,o=0;o<s[p+"-"+g].length;o++)v+=$(s[p+"-"+g][o]);M++}O()}for(o=0;o<e.length;o++)if(e[o].container===p&&e[o].children)for(_=1;_<e[o].children.length;_++)te(e[o].children[_]);for(O(),g=W-1;g>=0;g--)if(s[p+"-"+g])for(o=0;o<s[p+"-"+g].length;o++)H(s[p+"-"+g][o]);O();var w=Number.MAX_VALUE,k=-Number.MAX_VALUE;for(o=0;o<e.length;o++)e[o].container===p&&(""!==e[o].parent?e[o].visible&&e[e[o].pidx].visible&&ne.push([e[o].pidx,e[o].idx]):e[o].sibling&&null===ZC._n_(e[o].pidx)&&null!==ZC._n_(T[e[o].sibling])&&ne.push([T[e[o].sibling],e[o].idx]),e[o].visible&&(w=Math.min(w,e[o].coord),k=Math.max(k,e[o].coord)));w===k&&(k=w+I);var V,A=ie[p],N=function(e){for(var t=0,i=e;i>=0;i--)t+=Math.pow(2,i);return t};switch(Z){case"tree-radial":n=Math.min(A.width-ze-be,A.height-xe-me)/(2*Math.max(W,1)),0!==x&&(n=Math.pow(2,W-1)*Math.min(A.width-ze-be,A.height-xe-me)/N(W-1));break;case"tree-down":case"tree-up":n=(A.height-xe-me)/Math.max(W,1),0!==x&&(n=Math.pow(2,W-1)*(A.height-xe-me)/N(W-1));break;case"tree-left":case"tree-right":n=(A.width-ze-be)/Math.max(W,1),0!==x&&(n=Math.pow(2,W-1)*(A.width-be-ze)/N(W-1))}for(o=0;o<e.length;o++)if(e[o].visible&&e[o].container===p)switch(Z){case"tree-right":if(V=(A.height-xe-me)/(k-w),e[o].y=A.y+xe+(e[o].coord-w)*V,0===W&&(e[o].y+=A.height/2),e[o].x=A.x+be,0===x)e[o].x+=e[o].level*n;else if(-1===x)for(g=0;g<e[o].level;g++)e[o].x+=n*Math.pow(2,-g);else if(1===x)for(g=0;g<e[o].level;g++)e[o].x+=n*Math.pow(2,-W+g+1);break;case"tree-left":if(V=(A.height-xe-me)/(k-w),e[o].y=A.y+xe+(e[o].coord-w)*V,0===W&&(e[o].y+=A.height/2),e[o].x=A.x+A.width-ze,0===x)e[o].x-=e[o].level*n;else if(-1===x)for(g=0;g<e[o].level;g++)e[o].x-=n*Math.pow(2,-g);else if(1===x)for(g=0;g<e[o].level;g++)e[o].x-=n*Math.pow(2,-W+g+1);break;case"tree-down":if(V=(A.width-ze-be)/(k-w),e[o].x=A.x+be+(e[o].coord-w)*V,0===W&&(e[o].x+=A.width/2),e[o].y=A.y+xe,0===x)e[o].y+=e[o].level*n;else if(-1===x)for(g=0;g<e[o].level;g++)e[o].y+=n*Math.pow(2,-g);else if(1===x)for(g=0;g<e[o].level;g++)e[o].y+=n*Math.pow(2,-W+g+1);break;case"tree-up":if(V=(A.width-ze-be)/(k-w),e[o].x=A.x+be+(e[o].coord-w)*V,0===W&&(e[o].x+=A.width/2),e[o].y=A.y+A.height-me,0===x)e[o].y-=e[o].level*n;else if(-1===x)for(g=0;g<e[o].level;g++)e[o].y-=n*Math.pow(2,-g);else if(1===x)for(g=0;g<e[o].level;g++)e[o].y-=n*Math.pow(2,-W+g+1);break;case"tree-radial":if(V=z/(k-w+1),e[o].angle=m+(e[o].coord-w)*V,e[o].radius=0,0===x)e[o].radius+=e[o].level*n;else if(-1===x)for(g=0;g<e[o].level;g++)e[o].radius+=n*Math.pow(2,-g-1);else if(1===x)for(g=0;g<e[o].level;g++)e[o].radius+=n*Math.pow(2,-W+g);e[o].cx=A.x+be+(A.width-be-ze)/2,e[o].cy=A.y+xe+(A.height-xe-me)/2,D=ZC.AP.BN(e[o].cx,e[o].cy,e[o].radius,e[o].angle),e[o].x=D[0],e[o].y=D[1]}}var L={},X={},P=C?zingchart.plugins.tree.orgchart_defaults:zingchart.plugins.tree.tree_defaults;for(o=0;o<e.length;o++)if(e[o].visible&&!e[o].fake){c=e[o];var E,j=Math.round(b+(y-b)*(c.value-zingchart.plugins.tree[r.id].minValue)/(zingchart.plugins.tree[r.id].maxValue-zingchart.plugins.tree[r.id].minValue)),S={};if(ZC._cp_(P.node,S),ZC._cp_({id:"node_"+c.id,cls:"zctreeshape","background-color":f[c.level%f.length],"hover-state":{"background-color":ZC.AR.JU(f[c.level%f.length],20)},x:c.x,y:c.y,size:j,dataTreeIndex:c.idx},S),c.children&&c.children.length?ZC._cp_(P["node[parent]"],S):ZC._cp_(P["node[leaf]"],S),c.collapsed&&ZC._cp_(P["node[collapsed]"],S),ZC._cp_(u.node||{},S),c.children&&c.children.length?ZC._cp_(u["node[parent]"],S):ZC._cp_(u["node[leaf]"],S),c.collapsed&&ZC._cp_(u["node[collapsed]"],S),ZC._cp_(u["node[container-"+c.container+"]"],S),ZC._cp_(u["node[level-"+c.level+"]"],S),c.parent&&ZC._cp_(u["node[parent-"+e[c.pidx].id+"]"],S),c.cls)for(var U=c.cls.split(/\s/),F=0;F<U.length;F++)ZC._cp_(u["node[cls-"+U[F]+"]"],S);if(u.nodes&&u.nodes[c.id]&&ZC._cp_(u.nodes[c.id],S),u.nodes&&u.nodes[ZC.V8(c.id)]&&ZC._cp_(u.nodes[ZC.V8(c.id)],S),S.label&&(S.label.x=c.x,S.label.y=c.y,P.node.label_jsRule&&ZC._cp_(P.node.label_jsRule(c,S,Z),S.label)),S["js-rule"])try{var B=ZC.execFn(S["js-rule"].replace("javascript:","").replace("()",""),window,r.id,c,S);B&&ZC._cp_(B,S)}catch(Ce){}c.style&&ZC._cp_(c.style,S);var q={decimals:null,short:!1,"thousands-separator":",","decimals-separator":"."};if(ZC._cp_(S,q),S.label&&S.label.text){for(E in S.label.text=S.label.text.replace(/%text/gi,c.text).replace(/%node-value/gi,zingchart.formatNumber(c["node-value"],q)).replace(/%value/gi,zingchart.formatNumber(c.value,q)),c)"data-"===E.substring(0,5)&&(S.label.text=S.label.text.replace(new RegExp("%"+E,"g"),c[E]));S.label.text=S.label.text.replace(new RegExp("%data-([a-zA-Z0-9]+)","g"),"")}if(S.tooltip&&S.tooltip.text){for(E in ZC._cp_(S.tooltip,q),S.tooltip.text=S.tooltip.text.replace(/%text/gi,c.text).replace(/%node-value/gi,zingchart.formatNumber(c["node-value"],q)).replace(/%value/gi,zingchart.formatNumber(c.value,q)),c)"data-"===E.substring(0,5)&&(S.tooltip.text=S.tooltip.text.replace(new RegExp("%"+E,"g"),c[E]));S.tooltip.text=S.tooltip.text.replace(new RegExp("%data-([a-zA-Z0-9]+)","g"),"")}re.push(S),L[c.id]=[],L[c.id][0]=ZC._i_(S.width||S.size||"0"),L[c.id][1]=ZC._i_(S.height||S.size2||S.size||"0"),L[c.id][2]=ZC._i_(S["offset-x"]||"0"),L[c.id][3]=ZC._i_(S["offset-y"]||"0"),X[c.id]={size:ZC._i_(S[ZC._[21]]),type:S.type}}for(o=0;o<ne.length;o++){d=e[ne[o][0]],c=e[ne[o][1]];var ee={};if(ZC._cp_(P.link,ee),ZC._cp_({id:"link_"+c.idx+"_"+d.idx,cls:"zctreeshape",type:"line",flat:!0},ee),ZC._cp_(u.link||{},ee),ZC._cp_(u["link[level-"+d.level+"]"],ee),ZC._cp_(u["link[container-"+d.container+"]"],ee),ZC._cp_(u["link[parent-"+d.id+"]"],ee),!(c.sibling&&(d=e[T[c.sibling]],ee.aspect="sibling",ZC._cp_(u["link[sibling]"],ee),d.fake&&c.fake||c.fake&&!c.children))){if(ee["js-rule"])try{var le=ZC.execFn(ee["js-rule"].replace("javascript:","").replace("()",""),window,r.id,c,d,ee);le&&ZC._cp_(le,ee)}catch(Ce){}u.links&&u.links[d.id+"_"+c.id]&&ZC._cp_(u.links[d.id+"_"+c.id],ee);var ce,de,oe=[],he=c.x,se=c.y;L[c.id]&&(he+=L[c.id][2],se+=L[c.id][3]);var ge=d.x,_e=d.y;L[d.id]&&(ge+=L[d.id][2],_e+=L[d.id][3]);var pe=!0,ue=n;switch(ee.aspect){case"sibling":oe=[[he,se],[ge,_e]],pe=!0;break;case"side-before":case"side-after":"tree-down"===Z||"tree-up"===Z?(C||(ue=ZC._a_(_e-se)),oe=[[he,se],[ge+("side-after"===ee.aspect?1:-1)*L[d.id][0]/3,se],[ge+("side-after"===ee.aspect?1:-1)*L[d.id][0]/3,_e+("tree-down"===Z?1:-1)*ue/R],[ge+("side-after"===ee.aspect?1:-1)*L[d.id][0]/3,_e+("tree-down"===Z?1:-1)*ue/R],[ge+("side-after"===ee.aspect?1:-1)*L[d.id][0]/3,_e]]):(C||(ue=ZC._a_(ge-he)),oe=[[he,se],[he,_e+("side-after"===ee.aspect?-1:1)*L[d.id][1]/3],[ge+("tree-right"===Z?1:-1)*ue/R,_e+("side-after"===ee.aspect?-1:1)*L[d.id][1]/3],[ge+("tree-right"===Z?1:-1)*ue/R,_e+("side-after"===ee.aspect?-1:1)*L[d.id][1]/3],[ge,_e+("side-after"===ee.aspect?-1:1)*L[d.id][1]/3]]),pe=!0;break;case"side-between":oe=[[he,se],[ge,se],[ge,_e]],pe=!0;break;case"arc":if(Y=ZC.AP.K3(ge,_e,he,se),oe.push([ge,_e]),"tree-up"===Z||"tree-down"===Z)de=_e-Y[1],oe.push([ge,Y[1]+de/R,Y[0],Y[1]]),oe.push([he,Y[1]-de/R,he,se]);else if("tree-left"===Z||"tree-right"===Z)ce=ge-Y[0],oe.push([Y[0]+ce/R,_e,Y[0],Y[1]]),oe.push([Y[0]-ce/R,se,he,se]);else if("tree-radial"===Z&&d.level>0){var fe=ZC.AP.BN(ie[c.container].x+ie[c.container].width/2,ie[c.container].y+ie[c.container].height/2,d.radius+(c.radius-d.radius)/5,d.angle),Ze=ZC.AP.BN(ie[c.container].x+ie[c.container].width/2,ie[c.container].y+ie[c.container].height/2,d.radius+4*(c.radius-d.radius)/5,c.angle);oe.push([fe[0],fe[1],Y[0],Y[1]]),oe.push([Ze[0],Ze[1],he,se])}oe.push([he,se]),pe=!1;break;case"split":oe.push([ge,_e]),"tree-up"===Z||"tree-down"===Z?(C||(ue=ZC._a_(_e-se)),oe.push([ge,_e+ue/R*("tree-down"===Z?1:-1)]),oe.push([he,_e+ue/R*("tree-down"===Z?1:-1)])):"tree-left"===Z||"tree-right"===Z?(C||(ue=ZC._a_(ge-he)),oe.push([ge+ue/R*("tree-right"===Z?1:-1),_e]),oe.push([ge+ue/R*("tree-right"===Z?1:-1),se])):"tree-radial"===Z&&(D=ZC.AP.BN(ie[c.container].x+ie[c.container].width/2,ie[c.container].y+ie[c.container].height/2,d.radius+(c.radius-d.radius)/2,d.angle),oe.push([D[0],D[1]]),oe.push([ie[c.container].x+ie[c.container].width/2,ie[c.container].y+ie[c.container].height/2,d.radius+(c.radius-d.radius)/2,d.angle,c.angle,d.angle>c.angle?1:0])),oe.push([he,se]),pe=!1;break;case"line":oe=[[he,se],[ge,_e]],pe=!0}ee.points=oe,ee.visible=!0,pe?h(ee,L[c.id],X[c.id],L[d.id],X[d.id]):h(ee,L[d.id],X[d.id],L[c.id],X[c.id]),ae.push(ee)}}zingchart.exec(r.id,"removeobject",{type:"shape",cls:"zctreeshape"}),zingchart.exec(r.id,"addobject",{type:"shape",data:ae.concat(l(ae)).concat(re)})};if("graph"===Z){if(Ve(),!zingchart.plugins.tree[r.id].navSetup){var Ne=function(){_e=""};zingchart.bind(r.id,"shape_mousedown",function(e){if(0===e.ev.button&&0===e.shape.id.indexOf("node_")){var t=ZC.Q.MR(e.ev),i=ZC.A5("#"+r.id+"-top").offset();pe=[t[0]-i.left,t[1]-i.top],zingchart.bind(r.id,ZC._[49],Ne),_e=e.shape.id.replace("node_","")}}),zingchart.bind(r.id,"shape_mouseup",Ne),zingchart.bind(r.id,ZC._[48],function(e){""!==_e?(e.ev.preventDefault(),pe=[e.x,e.y],we(!0),(pe[0]<10||pe[0]>a.I-10||pe[1]<10||pe[1]>a.F-10)&&Ne(e)):"none"===e.target&&(c.L5(),c.A7&&c.A.A7&&c.A7.AO&&a.A7.onmouseout(e.ev))}),zingchart.bind(r.id,"beforedestroy",function(e){zingchart.plugins.tree[e.id]._render_graph_=null,zingchart.plugins.tree[e.id].navSetup=!1}),zingchart.plugins.tree[r.id].navSetup=!0}}else Ae(),j||zingchart.plugins.tree[r.id].navSetup||(zingchart.bind(r.id,"shape_click",function(e){0===e.shape.id.indexOf("node_")&&window.setTimeout(function(){!function(e){for(var t=zingchart.plugins.tree[r.id].data,i=F(e,!0),n=0;n<i.length;n++)0===n?t[i[n]].collapsed=!t[i[n]].collapsed:t[i[n]].visible=!t[i[n]].visible}(e["data-tree-index"]),Ae()},33)}),zingchart.plugins.tree[r.id].navSetup=!0)}};zingchart.bind(null,"gcomplete",function(e){a(e)}),zingchart.extendAPI("tree.addnode",function(e,t){if(zingchart.plugins.tree[e]&&t.data){var i=!0;null!==ZC._n_(t.update)&&(i=ZC._b_(t.update));var n=t.data;n.id=n.id||"N"+ZC._r_(1e4,99999),n.text=n.text||n.id,n.type="node",n[ZC._[9]]=n[ZC._[9]]||1,n.container=n.container||0,n.group=n.group||0,zingchart.plugins.tree[e].data.push(n),i&&(r(e),zingchart.plugins.tree[e]._render_graph_())}}),zingchart.extendAPI("tree.removenode",function(e,t){if(zingchart.plugins.tree[e]&&t.id){var i=!0;if(null!==ZC._n_(t.update)&&(i=ZC._b_(t.update)),!t.id)return;for(var n=zingchart.plugins.tree[e].data.length-1;n>=0;n--)"node"===zingchart.plugins.tree[e].data[n].type&&zingchart.plugins.tree[e].data[n].id===t.id?zingchart.plugins.tree[e].data.splice(n,1):("link"===zingchart.plugins.tree[e].data[n].type&&zingchart.plugins.tree[e].data[n].source===t.id||zingchart.plugins.tree[e].data[n].target===t.id)&&zingchart.plugins.tree[e].data.splice(n,1);i&&(r(e),zingchart.plugins.tree[e]._render_graph_())}}),zingchart.extendAPI("tree.getdata",function(e){return zingchart.plugins.tree[e]?zingchart.plugins.tree[e].data:null}),zingchart.extendAPI("tree.set",function(e,t){if(zingchart.plugins.tree[e]&&t.data){var i=!0;null!==ZC._n_(t.update)&&(i=ZC._b_(t.update));var n=t.data;null!==ZC._n_(n["attraction-constant"])&&(zingchart.plugins.tree[e].attractionConstant=ZC._f_(n["attraction-constant"])),null!==ZC._n_(n["repulsion-constant"])&&(zingchart.plugins.tree[e].repulsionConstant=ZC._i_(n["repulsion-constant"])),null!==ZC._n_(n["spring-length"])&&(zingchart.plugins.tree[e].springLength=ZC._f_(n["spring-length"])),i&&(r(e),zingchart.plugins.tree[e]._render_graph_())}return null}),zingchart.extendAPI("tree.addlink",function(e,t){if(zingchart.plugins.tree[e]&&t.data){var i=!0;null!==ZC._n_(t.update)&&(i=ZC._b_(t.update));var n=t.data;if(!n.source||!n.target)return;for(var a=0,l=0;l<zingchart.plugins.tree[e].data.length;l++)"node"===zingchart.plugins.tree[e].data[l].type&&(zingchart.plugins.tree[e].data[l].id!==n.source&&zingchart.plugins.tree[e].data[l].id!==n.target||a++);if(2!==a)return;n.type="link",n[ZC._[9]]=n[ZC._[9]]||1,zingchart.plugins.tree[e].data.push(n),i&&(r(e),zingchart.plugins.tree[e]._render_graph_())}}),zingchart.extendAPI("tree.removelink",function(e,t){if(zingchart.plugins.tree[e]&&t.data){var i=!0;null!==ZC._n_(t.update)&&(i=ZC._b_(t.update));var n=t.data;if(!n.source||!n.target)return;for(var a=zingchart.plugins.tree[e].data.length-1;a>=0;a--)(zingchart.plugins.tree[e].data[a].source===n.source&&zingchart.plugins.tree[e].data[a].target===n.target||zingchart.plugins.tree[e].data[a].source===n.target&&zingchart.plugins.tree[e].data[a].target===n.source)&&zingchart.plugins.tree[e].data.splice(a,1);i&&(r(e),zingchart.plugins.tree[e]._render_graph_())}})}function l(e){for(var t=[],i={},n=0;n<e.length;n++){var r=e[n],a=!0===r.visible;if(r["start-point"]||r["end-point"]){var l=o(r.points),h=l[0],s=l[1],g=l[2],_=l[3],p={specs:r["start-point"],id:r.id+"_startpoint",color:r["line-color"],lineWidth:r[ZC._[4]],tip:h,tail:s},u={specs:r["end-point"],id:r.id+"_endpoint",color:r["line-color"],lineWidth:r[ZC._[4]],tip:g,tail:_};r["start-point"]&&(!1===r.startSizeZero||r["start-point"]["allow-zero-nodes"])&&c(i,p),r["end-point"]&&(!1===r.endSizeZero||r["end-point"]["allow-zero-nodes"])&&c(i,u)}}for(var f in i)t.push(d(i[f],a));return t}function c(e,t){var i=t.tip[0].toString()+"_"+t.tip[1].toString()+"_"+t.tail[0].toString()+"_"+t.tail[1].toString();e[i]===undefined&&(e[i]=t)}function d(e,t){var i,n,r=[],a=(e.specs[ZC._[19]]||10)/2,l=e.specs.length||15;e.specs["allow-zero-nodes"];switch(e.specs.type){case"linearrow":n=!1,i=0;break;case"diamond":n=!0,l=(i=l)/2;break;case"triangle":n=!0,i=l;break;case"arrow":default:n=!0,i=.8*l}r.push([l,a]),r.push([0,0]),r.push([l,-a]),n&&(r.push([i,0]),r.push([l,a]));for(var c=Math.atan2(e.tail[1]-e.tip[1],e.tail[0]-e.tip[0]),d=Math.cos(-1*c),o=Math.sin(-1*c),h=0;h<r.length;h++){var s=r[h],g=d*s[0]+o*s[1],_=d*s[1]-o*s[0];s[0]=g+e.tip[0],s[1]=_+e.tip[1]}var p=e.specs[ZC._[61]]||e.color,u=e.specs[ZC._[0]]||e.color,f=e.specs[ZC._[62]]||e.lineWidth,Z={id:e.id,cls:"zctreeshape",flat:!0,points:r,visible:t};return n?(Z.type="poly",Z[ZC._[0]]=u,Z[ZC._[61]]=p,Z[ZC._[62]]=f):(Z.type="line",Z["line-color"]=p,Z[ZC._[4]]=f),Z}function o(e){var t=e.length;return[e[0],e[1],e[t-1],e[t-2]]}function h(e,t,i,n,r){var a=o(e.points);e.startSizeZero=!t||!p(a[0],a[1],_(t,i),i.type),e.endSizeZero=!n||!p(a[2],a[3],_(n,r),r.type)}function s(e,t,i){var n=o(e.points),r=g(t),a=g(i);e.startSizeZero=!p(n[0],n[1],[r.horzRadius,r.vertRadius],r.type),e.endSizeZero=!p(n[2],n[3],[a.horzRadius,a.vertRadius],a.type)}function g(e){var t,i;if(!e)return{horzRadius:10,vertRadius:10,type:"circle"};var n=e.type||"circle";switch(n){case"circle":case"square":t=ZC._i_(e.size),i=ZC._i_(e.size);break;case"rectangle":t=ZC._i_(e.width)/2,i=ZC._i_(e.height)/2;break;default:e[ZC._[21]]?(t=ZC._i_(e.size),i=ZC._i_(e.size)):(t=(ZC._i_(e[ZC._[19]])||0)/2,i=(ZC._i_(e[ZC._[20]])||0)/2)}return{horzRadius:t,vertRadius:i,type:n}}function _(e,t){var i,n;switch(t.type){case"circle":case"square":i=t.size,n=t.size;break;case"rectangle":i=e[0]/2,n=e[1]/2;break;default:t[ZC._[21]]?(i=t.size,n=t.size):(i=e[0]/2,n=e[1]/2)}return[i,n,e[2],e[3]]}function p(e,t,i,n){var r=i[0],a=i[1];i[2],i[3];if(e[1]==t[1]&&e[0]<=t[0])e[0]+=r;else if(e[1]==t[1]&&e[0]>t[0])e[0]-=r;else if(e[0]==t[0]&&e[1]<=t[1])e[1]+=a;else if(e[0]==t[0]&&e[1]>t[1])e[1]-=a;else switch(n){case"circle":var l=Math.atan2(t[1]-e[1],t[0]-e[0]);e[0]+=Math.cos(-1*l)*r,e[1]-=Math.sin(-1*l)*r;break;case"rectangle":default:var c,d=[e[0]-r,e[1]-a],o=[e[0]+r,e[1]-a],h=[e[0]-r,e[1]+a],s=[e[0]+r,e[1]+a];function g(e){return!isNaN(e[0])&&!isNaN(e[1])}g(c=u(d,o,e,t))?(e[0]=c[0],e[1]=c[1]):g(c=u(o,s,e,t))?(e[0]=c[0],e[1]=c[1]):g(c=u(s,h,e,t))?(e[0]=c[0],e[1]=c[1]):g(c=u(h,d,e,t))&&(e[0]=c[0],e[1]=c[1])}return 0!=r}function u(e,t,i,n){var r=ZC.AP.A67(e,t,i,n),a=[NaN,NaN];return isNaN(r[0])||isNaN(r[1])?a:r[0]>Math.max(e[0],t[0])||r[0]<Math.min(e[0],t[0])?a:r[1]>Math.max(e[1],t[1])||r[1]<Math.min(e[1],t[1])?a:n[0]>i[0]&&r[0]<i[0]?a:n[0]<i[0]&&r[0]>i[0]?a:n[1]>i[1]&&r[1]<i[1]?a:n[1]<i[1]&&r[1]>i[1]?a:r}}();