/* Copyright (c) 2010, Nicolas Garcia Belmonte All rights reserved > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are met: > * Redistributions of source code must retain the above copyright > notice, this list of conditions and the following disclaimer. > * Redistributions in binary form must reproduce the above copyright > notice, this list of conditions and the following disclaimer in the > documentation and/or other materials provided with the distribution. > * Neither the name of the organization nor the > names of its contributors may be used to endorse or promote products > derived from this software without specific prior written permission. > > THIS SOFTWARE IS PROVIDED BY NICOLAS GARCIA BELMONTE ``AS IS'' AND ANY > EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > DISCLAIMED. IN NO EVENT SHALL NICOLAS GARCIA BELMONTE BE LIABLE FOR ANY > DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS > SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function(){window.$jit=function(z){z=z||window;for(var A in $jit){if($jit[A].$extend){z[A]=$jit[A]}}};$jit.version="2.0.0a";var d=function(z){return document.getElementById(z)};d.empty=function(){};d.extend=function(B,z){for(var A in (z||{})){B[A]=z[A]}return B};d.lambda=function(z){return(typeof z=="function")?z:function(){return z}};d.time=Date.now||function(){return +new Date};d.splat=function(A){var z=d.type(A);return z?((z!="array")?[A]:A):[]};d.type=function(A){var z=d.type.s.call(A).match(/^\[object\s(.*)\]$/)[1].toLowerCase();if(z!="object"){return z}if(A&&A.$$family){return A.$$family}return(A&&A.nodeName&&A.nodeType==1)?"element":z};d.type.s=Object.prototype.toString;d.each=function(E,D){var C=d.type(E);if(C=="object"){for(var B in E){D(E[B],B)}}else{for(var A=0,z=E.length;A>16,B>>8&255,B&255]}};d.rgbToHsl=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=(z+C)/2;if(z==C){E=D=0}else{var F=z-C;D=A>0.5?F/(2-z-C):F/(z+C);switch(z){case r:E=(g-b)/F+(g1){J-=1}if(J<1/6){return L+(K-L)*6*J}if(J<1/2){return K}if(J<2/3){return L+(K-L)*(2/3-J)*6}return L}var A=E<0.5?E*(1+I):E+I-E*I;var B=2*E-A;z=C(B,A,F+1/3);G=C(B,A,F);H=C(B,A,F-1/3)}return[Math.round(z*255),Math.round(G*255),Math.round(H*255)]};d.hslToHex=function(z){return d.rgbToHex(d.hslToRgb(z))};d.rgbToHsv=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=z;var F=z-C;D=z==0?0:F/z;if(z==C){E=0}else{switch(z){case r:E=(g-b)/F+(g-1};d.addClass=function(A,z){if(!d.hasClass(A,z)){A.className=(A.className+" "+z)}};d.removeClass=function(A,z){A.className=A.className.replace(new RegExp("(^|\\s)"+z+"(?:\\s|$)"),"$1")};d.getPos=function(B){var E=D(B);var z=C(B);return{x:E.x-z.x,y:E.y-z.y};function D(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.offsetLeft;F.y+=G.offsetTop;G=G.offsetParent}return F}function C(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.scrollLeft;F.y+=G.scrollTop;G=G.parentNode}return F}function A(F){return(/^(?:body|html)$/i).test(F.tagName)}};d.event={get:function(A,z){z=z||window;return A||z.event},getWheel:function(z){return z.wheelDelta?z.wheelDelta/120:-(z.detail||0)/3},isRightClick:function(z){return(z.which==3||z.button==2)},getPos:function(C,B){B=B||window;C=C||B.event;var A=B.document;A=A.documentElement||A.body;if(C.touches&&C.touches.length){C=C.touches[0]}var z={x:C.pageX||(C.clientX+A.scrollLeft),y:C.pageY||(C.clientY+A.scrollTop)};return z},stop:function(z){if(z.stopPropagation){z.stopPropagation()}z.cancelBubble=true;if(z.preventDefault){z.preventDefault()}else{z.returnValue=false}}};$jit.util=$jit.id=d;var t=function(A){A=A||{};var z=function(){for(var D in this){if(typeof this[D]!="function"){this[D]=d.unlink(this[D])}}this.constructor=z;if(t.prototyping){return this}var C=this.initialize?this.initialize.apply(this,arguments):this;this.$$family="class";return C};for(var B in t.Mutators){if(!A[B]){continue}A=t.Mutators[B](A,A[B]);delete A[B]}d.extend(z,this);z.constructor=t;z.prototype=A;return z};t.Mutators={Implements:function(z,A){d.each(d.splat(A),function(C){t.prototyping=C;var B=(typeof C=="function")?new C:C;for(var D in B){if(!(D in z)){z[D]=B[D]}}delete t.prototyping});return z}};d.extend(t,{inherit:function(z,C){for(var B in C){var A=C[B];var E=z[B];var D=d.type(A);if(E&&D=="function"){if(A!=E){t.override(z,B,A)}}else{if(D=="object"){z[B]=d.merge(E,A)}else{z[B]=A}}}return z},override:function(A,z,D){var C=t.prototyping;if(C&&A[z]!=C[z]){C=null}var B=function(){var E=this.parent;this.parent=C?C[z]:A[z];var F=D.apply(this,arguments);this.parent=E;return F};A[z]=B}});t.prototype.implement=function(){var z=this.prototype;d.each(Array.prototype.slice.call(arguments||[]),function(A){t.inherit(z,A)});return this};$jit.Class=t;$jit.json={prune:function(A,z){this.each(A,function(C,B){if(B==z&&C.children){delete C.children;C.children=[]}})},getParent:function(z,D){if(z.id==D){return false}var C=z.children;if(C&&C.length>0){for(var B=0;B=(7-4*C)/11){D=B*B-Math.pow((11-6*C-11*E)/4,2);break}}return D},Elastic:function(C,B){return Math.pow(2,10*--C)*Math.cos(20*C*Math.PI*(B[0]||1)/3)}};d.each(A,function(C,B){k[B]=z(C)});d.each(["Quad","Cubic","Quart","Quint"],function(C,B){k[C]=z(function(D){return Math.pow(D,[B+2])})})})();var x=new t({initialize:function(z){this.setOptions(z)},setOptions:function(z){var A={duration:2500,fps:40,transition:k.Quart.easeInOut,compute:d.empty,complete:d.empty,link:"ignore"};this.opt=d.merge(A,z||{});return this},step:function(){var A=d.time(),z=this.opt;if(AE.height)?(G.y-D.height-F):G.y+F)+"px";B.left=((G.x+D.width+z>E.width)?(G.x-D.width-z):G.x+z)+"px"},hide:function(z){this.tip.style.display="none";z&&this.config.onHide()}});q.Classes.NodeStyles=new t({Implements:[w,j],initializePost:function(){this.fx=this.viz.fx;this.types=this.viz.fx.nodeTypes;this.nStyles=this.config;this.nodeStylesOnHover=this.nStyles.stylesHover;this.nodeStylesOnClick=this.nStyles.stylesClick;this.hoveredNode=false;this.fx.nodeFxAnimation=new x();this.down=false;this.move=false},onMouseOut:function(B,A){this.down=this.move=false;if(!this.hoveredNode){return}if(this.dom&&this.isLabel(B,A)){this.toggleStylesOnHover(this.hoveredNode,false)}var z=B.relatedTarget,C=this.canvas.getElement();while(z&&z.parentNode){if(C==z.parentNode){return}z=z.parentNode}this.toggleStylesOnHover(this.hoveredNode,false);this.hoveredNode=false},onMouseOver:function(C,B){var z;if(this.dom&&(z=this.isLabel(C,B))){var A=this.viz.graph.getNode(z.id);if(A.selected){return}this.hoveredNode=A;this.toggleStylesOnHover(this.hoveredNode,true)}},onMouseDown:function(D,C,A,B){if(B){return}var z;if(this.dom&&(z=this.isLabel(D,C))){this.down=this.viz.graph.getNode(z.id)}else{if(!this.dom){this.down=A.getNode()}}this.move=false},onMouseUp:function(C,B,z,A){if(A){return}if(!this.move){this.onClick(z.getNode())}this.down=this.move=false},getRestoredStyles:function(A,z){var C={},B=this["nodeStylesOn"+z];for(var D in B){C[D]=A.styles["$"+D]}return C},toggleStylesOnHover:function(z,A){if(this.nodeStylesOnHover){this.toggleStylesOn("Hover",z,A)}},toggleStylesOnClick:function(z,A){if(this.nodeStylesOnClick){this.toggleStylesOn("Click",z,A)}},toggleStylesOn:function(D,z,F){var G=this.viz;var E=this.nStyles;if(F){var C=this;if(!z.styles){z.styles=d.merge(z.data,{})}for(var H in this["nodeStylesOn"+D]){var A="$"+H;if(!(A in z.styles)){z.styles[A]=z.getData(H)}}G.fx.nodeFx(d.extend({elements:{id:z.id,properties:C["nodeStylesOn"+D]},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}else{var B=this.getRestoredStyles(z,D);G.fx.nodeFx(d.extend({elements:{id:z.id,properties:B},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}},onClick:function(z){if(!z){return}var A=this.nodeStylesOnClick;if(!A){return}if(z.selected){this.toggleStylesOnClick(z,false);delete z.selected}else{this.viz.graph.eachNode(function(C){if(C.selected){for(var B in A){C.setData(B,C.styles["$"+B],"end")}delete C.selected}});this.toggleStylesOnClick(z,true);z.selected=true;delete z.hovered;this.hoveredNode=false}},onMouseMove:function(F,E,C){if(this.down){this.move=true}if(this.dom&&this.isLabel(F,E)){return}var D=this.nodeStylesOnHover;if(!D){return}if(!this.dom){if(this.hoveredNode){var A=this.types[this.hoveredNode.getData("type")];var z=A&&A.contains&&A.contains.call(this.fx,this.hoveredNode,C.getPos());if(z){return}}var B=C.getNode();if(!this.hoveredNode&&!B){return}if(B.hovered){return}if(B&&!B.selected){this.fx.nodeFxAnimation.stopTimer();this.viz.graph.eachNode(function(H){if(H.hovered&&!H.selected){for(var G in D){H.setData(G,H.styles["$"+G],"end")}delete H.hovered}});B.hovered=true;this.hoveredNode=B;this.toggleStylesOnHover(B,true)}else{if(this.hoveredNode&&!this.hoveredNode.selected){this.fx.nodeFxAnimation.stopTimer();this.toggleStylesOnHover(this.hoveredNode,false);delete this.hoveredNode.hovered;this.hoveredNode=false}}}}});q.Classes.Navigation=new t({Implements:[w,j],initializePost:function(){this.pos=false;this.pressed=false},onMouseWheel:function(C,B,z){if(!this.config.zooming){return}d.event.stop(d.event.get(C,B));var D=this.config.zooming/1000,A=1+z*D;this.canvas.scale(A,A)},onMouseDown:function(E,D,C){if(!this.config.panning){return}if(this.config.panning=="avoid nodes"&&C.getNode()){return}this.pressed=true;this.pos=C.getPos();var B=this.canvas,A=B.translateOffsetX,z=B.translateOffsetY,G=B.scaleOffsetX,F=B.scaleOffsetY;this.pos.x*=G;this.pos.x+=A;this.pos.y*=F;this.pos.y+=z},onMouseMove:function(E,D,G){if(!this.config.panning){return}if(!this.pressed){return}if(this.config.panning=="avoid nodes"&&G.getNode()){return}var C=this.pos,F=G.getPos(),A=this.canvas,B=A.translateOffsetX,z=A.translateOffsetY,K=A.scaleOffsetX,I=A.scaleOffsetY;F.x*=K;F.y*=I;F.x+=B;F.y+=z;var J=F.x-C.x,H=F.y-C.y;this.pos=F;this.canvas.translate(J*1/K,H*1/I)},onMouseUp:function(C,B,A,z){if(!this.config.panning){return}this.pressed=false}});var n;(function(){var z=typeof HTMLCanvasElement,B=(z=="object"||z=="function");function A(C,D){var E=document.createElement(C);for(var F in D){if(typeof D[F]=="object"){d.extend(E[F],D[F])}else{E[F]=D[F]}}if(C=="canvas"&&!B&&G_vmlCanvasManager){E=G_vmlCanvasManager.initElement(document.body.appendChild(E))}return E}$jit.Canvas=n=new t({canvases:[],pos:false,element:false,labelContainer:false,translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(N,H){this.viz=N;this.opt=H;var E=d.type(H.injectInto)=="string"?H.injectInto:H.injectInto.id,F=E+"-label",C=d(E),G=H.width||C.offsetWidth,O=H.height||C.offsetHeight;this.id=E;var I={injectInto:E,width:G,height:O};this.element=A("div",{id:E+"-canvaswidget",style:{position:"relative",width:G+"px",height:O+"px"}});this.labelContainer=this.createLabelContainer(H.Label.type,F,I);this.canvases.push(new n.Base({config:d.extend({idSuffix:"-canvas"},I),plot:function(P){N.fx.plot()},resize:function(){N.refresh()}}));var J=H.background;if(J){var M=new n.Background[J.type](N,d.extend(J,I));this.canvases.push(new n.Base(M))}var L=this.canvases.length;while(L--){this.element.appendChild(this.canvases[L].canvas);if(L>0){this.canvases[L].plot()}}this.element.appendChild(this.labelContainer);C.appendChild(this.element);var D=null,K=this;d.addEvent(window,"scroll",function(){clearTimeout(D);D=setTimeout(function(){K.getPos(true)},500)})},getCtx:function(C){return this.canvases[C||0].getCtx()},getConfig:function(){return this.opt},getElement:function(){return this.element},getSize:function(C){return this.canvases[C||0].getSize()},resize:function(G,C){this.getPos(true);this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;for(var E=0,D=this.canvases.length;EH){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H))*I))}}else{if(G>=C){if(E>H){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H-F))*I))}}else{D=A((H+(E-H)*I))}}var z=(this.rho-B.rho)*I+B.rho;return{theta:D,rho:z}}};var m=function(A,z){return new c(A,z)};c.KER=m(0,0);var s=function(z,A){this.x=z;this.y=A};$jit.Complex=s;s.prototype={getc:function(){return this},getp:function(z){return this.toPolar(z)},set:function(z){z=z.getc(true);this.x=z.x;this.y=z.y},setc:function(z,A){this.x=z;this.y=A},setp:function(A,z){this.x=Math.cos(A)*z;this.y=Math.sin(A)*z},clone:function(){return new s(this.x,this.y)},toPolar:function(B){var z=this.norm();var A=Math.atan2(this.y,this.x);if(A<0){A+=Math.PI*2}if(B){return{theta:A,rho:z}}return new c(A,z)},norm:function(){return Math.sqrt(this.squaredNorm())},squaredNorm:function(){return this.x*this.x+this.y*this.y},add:function(z){return new s(this.x+z.x,this.y+z.y)},prod:function(z){return new s(this.x*z.x-this.y*z.y,this.y*z.x+this.x*z.y)},conjugate:function(){return new s(this.x,-this.y)},scale:function(z){return new s(this.x*z,this.y*z)},equals:function(z){return this.x==z.x&&this.y==z.y},$add:function(z){this.x+=z.x;this.y+=z.y;return this},$prod:function(B){var z=this.x,A=this.y;this.x=z*B.x-A*B.y;this.y=A*B.x+z*B.y;return this},$conjugate:function(){this.y=-this.y;return this},$scale:function(z){this.x*=z;this.y*=z;return this},$div:function(C){var z=this.x,B=this.y;var A=C.squaredNorm();this.x=z*C.x+B*C.y;this.y=B*C.x-z*C.y;return this.$scale(1/A)}};var u=function(A,z){return new s(A,z)};s.KER=u(0,0);$jit.Graph=new t({initialize:function(B,A,z,F){var D={complex:false,Node:{}};this.Node=A;this.Edge=z;this.Label=F;this.opt=d.merge(D,B||{});this.nodes={};this.edges={};var C=this;this.nodeList={};for(var E in l){C.nodeList[E]=(function(G){return function(){var H=Array.prototype.slice.call(arguments);C.eachNode(function(I){I[G].apply(I,H)})}})(E)}},getNode:function(z){if(this.hasNode(z)){return this.nodes[z]}return false},getByName:function(z){for(var B in this.nodes){var A=this.nodes[B];if(A.name==z){return A}}return false},getAdjacence:function(A,z){if(A in this.edges){return this.edges[A][z]}return false},addNode:function(A){if(!this.nodes[A.id]){var z=this.edges[A.id]={};this.nodes[A.id]=new f.Node(d.extend({id:A.id,name:A.name,data:A.data||{},adjacencies:z},this.opt.Node),this.opt.complex,this.Node,this.Edge,this.Label)}return this.nodes[A.id]},addAdjacence:function(C,B,A){if(!this.hasNode(C.id)){this.addNode(C)}if(!this.hasNode(B.id)){this.addNode(B)}C=this.nodes[C.id];B=this.nodes[B.id];var D=this.edges[C.id]=this.edges[C.id]||{};var z=this.edges[B.id]=this.edges[B.id]||{};D[B.id]=z[C.id]=new f.Adjacence(C,B,A,this.Edge,this.Label);return D[B.id]},removeNode:function(B){if(this.hasNode(B)){delete this.nodes[B];var A=this.edges[B];for(var z in A){delete this.edges[z][B]}delete this.edges[B]}},removeAdjacence:function(A,z){delete this.edges[A][z];delete this.edges[z][A]},hasNode:function(z){return z in this.nodes},empty:function(){this.nodes={};this.edges={}}});var f=$jit.Graph;var l;(function(){var z=function(G,I,D,F,H){var E;D=D||"current";G="$"+(G?G+"-":"");if(D=="current"){E=this.data}else{if(D=="start"){E=this.startData}else{if(D=="end"){E=this.endData}}}var C=G+I;if(F){return E[C]}if(!this.Config.overridable){return H[I]||0}return(C in E)?E[C]:((C in this.data)?this.data[C]:(H[I]||0))};var B=function(F,G,E,C){C=C||"current";F="$"+(F?F+"-":"");var D;if(C=="current"){D=this.data}else{if(C=="start"){D=this.startData}else{if(C=="end"){D=this.endData}}}D[F+G]=E};var A=function(E,C){E="$"+(E?E+"-":"");var D=this;d.each(C,function(G){var F=E+G;delete D.data[F];delete D.endData[F];delete D.startData[F]})};l={getData:function(E,C,D){return z.call(this,"",E,C,D,this.Config)},setData:function(E,D,C){B.call(this,"",E,D,C)},setDataset:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E=I&&L<=J&&z(K)){E(K,L)}if(LL){B(N,I,J)}})}})(D,H+G,A+G)},eachSubgraph:function(A,B,z){this.eachLevel(A,0,false,B,z)},eachSubnode:function(A,B,z){this.eachLevel(A,1,1,B,z)},anySubnode:function(C,B,A){var z=false;B=B||d.lambda(true);var D=d.type(B)=="string"?function(E){return E[B]}:B;this.eachSubnode(C,function(E){if(D(E)){z=true}},A);return z},getSubnodes:function(E,F,z){var B=[],D=this;F=F||0;var C,A;if(d.type(F)=="array"){C=F[0];A=F[1]}else{C=F;A=Number.MAX_VALUE-E._depth}this.eachLevel(E,C,A,function(G){B.push(G)},z);return B},getParents:function(A){var z=[];this.eachAdjacency(A,function(B){var C=B.nodeTo;if(C._depth1000||C.b>1000||C.ratio<0){I.beginPath();I.moveTo(G.x*z,G.y*z);I.lineTo(H.x*z,H.y*z);I.stroke()}else{var F=Math.atan2(H.y-C.y,H.x-C.x);var E=Math.atan2(G.y-C.y,G.x-C.x);var A=A(F,E);I.beginPath();I.arc(C.x*z,C.y*z,C.ratio*z,F,E,A);I.stroke()}function D(V,U){var N=(V.x*U.y-V.y*U.x),J=N;var M=V.squaredNorm(),L=U.squaredNorm();if(N==0){return{x:0,y:0,ratio:-1}}var T=(V.y*L-U.y*M+V.y-U.y)/N;var R=(U.x*M-V.x*L+U.x-V.x)/J;var S=-T/2;var Q=-R/2;var P=(T*T+R*R)/4-1;if(P<0){return{x:0,y:0,ratio:-1}}var O=Math.sqrt(P);var K={x:S,y:Q,ratio:O>1000?-1:O,a:T,b:R};return K}function A(J,K){return(JK)?false:true):((K+Math.PI>J)?true:false)}}};f.Plot={nodeHelper:a,edgeHelper:o,Interpolator:{map:{border:"color",color:"color",width:"number",height:"number",dim:"number",alpha:"number",lineWidth:"number",angularWidth:"number",span:"number",valueArray:"array-number",dimArray:"array-number"},canvas:{globalAlpha:"number",fillStyle:"color",strokeStyle:"color",lineWidth:"number",shadowBlur:"number",shadowColor:"color",shadowOffsetX:"number",shadowOffsetY:"number",miterLimit:"number"},label:{size:"number",color:"color"},compute:function(B,A,z){return B+(A-B)*z},moebius:function(E,D,G,A){var C=A.scale(-G);if(C.norm()<1){var z=C.x,F=C.y;var B=E.startPos.getc().moebiusTransformation(C);E.pos.setc(B.x,B.y);C.x=z;C.y=F}},linear:function(A,z,D){var C=A.startPos.getc(true);var B=A.endPos.getc(true);A.pos.setc(this.compute(C.x,B.x,D),this.compute(C.y,B.y,D))},polar:function(B,A,E){var D=B.startPos.getp(true);var C=B.endPos.getp();var z=C.interpolate(D,E);B.pos.setp(z.theta,z.rho)},number:function(A,F,E,z,D){var C=A[z](F,"start");var B=A[z](F,"end");A[D](F,this.compute(C,B,E))},color:function(B,z,H,E,C){var F=d.hexToRgb(B[E](z,"start"));var G=d.hexToRgb(B[E](z,"end"));var D=this.compute;var A=d.rgbToHex([parseInt(D(F[0],G[0],H)),parseInt(D(F[1],G[1],H)),parseInt(D(F[2],G[2],H))]);B[C](z,A)},"array-number":function(C,B,M,J,E){var K=C[J](B,"start"),L=C[J](B,"end"),N=[];for(var H=0,D=K.length;H=0.95){F.labels.plotLabel(B,K,A)}else{F.labels.hideLabel(K,false)}}H.restore();K.visited=!C})},plotTree:function(D,A,H){var E=this,F=this.viz,B=F.canvas,C=this.config,G=B.getCtx();var z=D.getData("alpha");D.eachSubnode(function(J){if(A.plotSubtree(D,J)&&J.exist&&J.drawn){var I=D.getAdjacency(J.id);!H&&A.onBeforePlotLine(I);G.globalAlpha=Math.min(z,J.getData("alpha"));E.plotLine(I,B,H);!H&&A.onAfterPlotLine(I);E.plotTree(J,A,H)}});if(D.drawn){!H&&A.onBeforePlotNode(D);this.plotNode(D,B,H);!H&&A.onAfterPlotNode(D);if(!A.hideLabels&&A.withLabels&&z>=0.95){this.labels.plotLabel(B,D,A)}else{this.labels.hideLabel(D,false)}}else{this.labels.hideLabel(D,true)}},plotNode:function(B,A,I){var F=B.getData("type"),E=this.node.CanvasStyles;if(F!="none"){var z=B.getData("lineWidth"),D=B.getData("color"),C=B.getData("alpha"),G=A.getCtx();G.lineWidth=z;G.fillStyle=G.strokeStyle=D;G.globalAlpha=C;for(var H in E){G[H]=B.getCanvasStyle(H)}this.nodeTypes[F].render.call(this,B,A,I)}},plotLine:function(E,A,H){var D=E.getData("type"),C=this.edge.CanvasStyles;if(D!="none"){var z=E.getData("lineWidth"),B=E.getData("color"),F=A.getCtx();F.lineWidth=z;F.fillStyle=F.strokeStyle=B;for(var G in C){F[G]=E.getCanvasStyle(G)}this.edgeTypes[D].call(this,E,A,H)}}};f.Label={};f.Label.Native=new t({plotLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.font=C.getLabelData("style")+" "+C.getLabelData("size")+"px "+C.getLabelData("family");z.textAlign=C.getLabelData("textAlign");z.fillStyle=z.strokeStyle=C.getLabelData("color");z.textBaseline=C.getLabelData("textBaseline");this.renderLabel(B,C,A)},renderLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.fillText(C.name,D.x,D.y+C.getData("height")/2)},hideLabel:d.empty,hideLabels:d.empty});f.Label.DOM=new t({labelsHidden:false,labelContainer:false,labels:{},getLabelContainer:function(){return this.labelContainer?this.labelContainer:this.labelContainer=document.getElementById(this.viz.config.labelContainer)},getLabel:function(z){return(z in this.labels&&this.labels[z]!=null)?this.labels[z]:this.labels[z]=document.getElementById(z)},hideLabels:function(A){var z=this.getLabelContainer();if(A){z.style.display="none"}else{z.style.display=""}this.labelsHidden=A},clearLabels:function(z){for(var A in this.labels){if(z||!this.viz.graph.hasNode(A)){this.disposeLabel(A);delete this.labels[A]}}},disposeLabel:function(A){var z=this.getLabel(A);if(z&&z.parentNode){z.parentNode.removeChild(z)}},hideLabel:function(D,z){D=d.splat(D);var A=z?"":"none",B,C=this;d.each(D,function(F){var E=C.getLabel(F.id);if(E){E.style.display=A}})},fitsInCanvas:function(B,z){var A=z.getSize();if(B.x>=A.width||B.x<0||B.y>=A.height||B.y<0){return false}return true}});f.Label.HTML=new t({Implements:f.Label.DOM,plotLabel:function(C,D,B){var E=D.id,z=this.getLabel(E);if(!z&&!(z=document.getElementById(E))){z=document.createElement("div");var A=this.getLabelContainer();z.id=E;z.className="node";z.style.position="absolute";B.onCreateLabel(z,D);A.appendChild(z);this.labels[D.id]=z}this.placeLabel(z,D,B)}});f.Label.SVG=new t({Implements:f.Label.DOM,plotLabel:function(C,E,B){var G=E.id,z=this.getLabel(G);if(!z&&!(z=document.getElementById(G))){var D="http://www.w3.org/2000/svg";z=document.createElementNS(D,"svg:text");var F=document.createElementNS(D,"svg:tspan");z.appendChild(F);var A=this.getLabelContainer();z.setAttribute("id",G);z.setAttribute("class","node");A.appendChild(z);B.onCreateLabel(z,E);this.labels[E.id]=z}this.placeLabel(z,E,B)}});f.Geom=new t({initialize:function(z){this.viz=z;this.config=z.config;this.node=z.config.Node;this.edge=z.config.Edge},translate:function(A,z){z=d.splat(z);this.viz.graph.eachNode(function(B){d.each(z,function(C){B.getPos(C).$add(A)})})},setRightLevelToShow:function(C,z,E){var D=this.getRightLevelToShow(C,z),B=this.viz.labels,A=d.merge({execShow:true,execHide:true,onHide:d.empty,onShow:d.empty},E||{});C.eachLevel(0,this.config.levelsToShow,function(G){var F=G._depth-C._depth;if(F>D){A.onHide(G);if(A.execHide){G.drawn=false;G.exist=false;B.hideLabel(G,false)}}else{A.onShow(G);if(A.execShow){G.exist=true}}});C.drawn=true},getRightLevelToShow:function(C,A){var z=this.config;var D=z.levelsToShow;var B=z.constrained;if(!B){return D}while(!this.treeFitsInCanvas(C,A,D)&&D>1){D--}return D}});var e={construct:function(A){var B=(d.type(A)=="array");var z=new f(this.graphOptions,this.config.Node,this.config.Edge,this.config.Label);if(!B){(function(C,E){C.addNode(E);if(E.children){for(var D=0,F=E.children;DF?I:F;G.setData("width",H);G.setData("height",H);G.setData("dim",H)}}})},initializeLabel:function(z){if(!this.label){this.label=document.createElement("div");document.body.appendChild(this.label)}this.setLabelStyles(z)},setLabelStyles:function(z){d.extend(this.label.style,{visibility:"hidden",position:"absolute",width:"auto",height:"auto"});this.label.className="jit-autoadjust-label"}};i.Tree=(function(){var I=Array.prototype.slice;function G(S,N,K,Q,L){var P=N.Node;var M=N.multitree;if(P.overridable){var R=-1,O=-1;S.eachNode(function(V){if(V._depth==K&&(!M||("$orn" in V.data)&&V.data.$orn==Q)){var T=V.getData("width",L);var U=V.getData("height",L);R=(R0)?H[0]:null;G(H)}for(var C=0,D=[F.id].concat(A);C=G._depth)});for(var E=0;E0&&M.drawn){M.drawn=false;A[D.id].push(M)}else{if((!H||!G)&&M.drawn){M.drawn=false;A[D.id].push(M)}}});D.drawn=true}if(z.length>0){I.fx.plot()}for(E in A){d.each(A[E],function(M){M.drawn=true})}for(E=0;Ez?B:z)+this.config.subtreeOffset},getEdge:function(E,D,C){var A=function(H,G){return function(){return E.pos.add(new s(H,G))}};var F=this.node;var z=E.getData("width");var B=E.getData("height");if(D=="begin"){if(F.align=="center"){return this.dispatch(C,A(0,B/2),A(-z/2,0),A(0,-B/2),A(z/2,0))}else{if(F.align=="left"){return this.dispatch(C,A(0,B),A(0,0),A(0,0),A(z,0))}else{if(F.align=="right"){return this.dispatch(C,A(0,0),A(-z,0),A(0,-B),A(0,0))}else{throw"align: not implemented"}}}}else{if(D=="end"){if(F.align=="center"){return this.dispatch(C,A(0,-B/2),A(z/2,0),A(0,B/2),A(-z/2,0))}else{if(F.align=="left"){return this.dispatch(C,A(0,0),A(z,0),A(0,B),A(0,0))}else{if(F.align=="right"){return this.dispatch(C,A(0,-B),A(0,0),A(0,0),A(-z,0))}else{throw"align: not implemented"}}}}}},getScaledTreePosition:function(D,F){var E=this.node;var z=D.getData("width");var C=D.getData("height");var B=(this.config.multitree&&("$orn" in D.data)&&D.data.$orn)||this.config.orientation;var A=function(H,G){return function(){return D.pos.add(new s(H,G)).$scale(1-F)}};if(E.align=="left"){return this.dispatch(B,A(0,C),A(0,0),A(0,0),A(z,0))}else{if(E.align=="center"){return this.dispatch(B,A(0,C/2),A(-z/2,0),A(0,-C/2),A(z/2,0))}else{if(E.align=="right"){return this.dispatch(B,A(0,0),A(-z,0),A(0,-C),A(0,0))}else{throw"align: not implemented"}}}},treeFitsInCanvas:function(E,z,F){var B=z.getSize();var C=(this.config.multitree&&("$orn" in E.data)&&E.data.$orn)||this.config.orientation;var A=this.dispatch(C,B.width,B.height);var D=this.getTreeBaseSize(E,F,function(H,G){return H===0||!G.anySubnode()});return(D=0){C.drawn=false;var G=A.getCtx();var E=F.geom.getScaledTreePosition(C,D);G.translate(E.x,E.y);G.scale(D,D)}this.plotTree(C,d.merge(z,{withLabels:true,hideLabels:!!D,plotSubtree:function(L,J){var I=B.multitree&&!("$orn" in C.data);var K=I&&C.getData("orns");return !I||K.indexOf(elem.getData("orn"))>-1}}),H);if(D>=0){C.drawn=true}},getAlignedPos:function(E,C,z){var B=this.node;var D,A;if(B.align=="center"){D={x:E.x-C/2,y:E.y-z/2}}else{if(B.align=="left"){A=this.config.orientation;if(A=="bottom"||A=="top"){D={x:E.x-C/2,y:E.y}}else{D={x:E.x,y:E.y-z/2}}}else{if(B.align=="right"){A=this.config.orientation;if(A=="bottom"||A=="top"){D={x:E.x-C/2,y:E.y-z}}else{D={x:E.x-C,y:E.y-z/2}}}else{throw"align: not implemented"}}}return D},getOrientation:function(z){var B=this.config;var A=B.orientation;if(B.multitree){var C=z.nodeFrom;var D=z.nodeTo;A=(("$orn" in C.data)&&C.data.$orn)||(("$orn" in D.data)&&D.data.$orn)}return A}});$jit.ST.Label={};$jit.ST.Label.Native=new t({Implements:f.Label.Native,renderLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.fillText(C.name,D.x,D.y)}});$jit.ST.Label.DOM=new t({Implements:f.Label.DOM,placeLabel:function(R,L,H){var D=L.pos.getc(true),Q=this.viz.config,M=Q.Node,z=this.viz.canvas,E=L.getData("width"),O=L.getData("height"),A=z.getSize(),I,P;var C=z.translateOffsetX,B=z.translateOffsetY,G=z.scaleOffsetX,F=z.scaleOffsetY,K=D.x*G+C,J=D.y*F+B;if(M.align=="center"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J-O/2+A.height/2)}}else{if(M.align=="left"){P=Q.orientation;if(P=="bottom"||P=="top"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J+A.height/2)}}else{I={x:Math.round(K+A.width/2),y:Math.round(J-O/2+A.height/2)}}}else{if(M.align=="right"){P=Q.orientation;if(P=="bottom"||P=="top"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J-O+A.height/2)}}else{I={x:Math.round(K-E+A.width/2),y:Math.round(J-O/2+A.height/2)}}}else{throw"align: not implemented"}}}var N=R.style;N.left=I.x+"px";N.top=I.y+"px";N.display=this.fitsInCanvas(I,z)?"":"none";H.onPlaceLabel(R,L)}});$jit.ST.Label.SVG=new t({Implements:[$jit.ST.Label.DOM,f.Label.SVG],initialize:function(z){this.viz=z}});$jit.ST.Label.HTML=new t({Implements:[$jit.ST.Label.DOM,f.Label.HTML],initialize:function(z){this.viz=z}});$jit.ST.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(A,z){var C=A.getData("dim"),D=this.getAlignedPos(A.pos.getc(true),C,C),B=C/2;this.nodeHelper.circle.render("fill",{x:D.x+B,y:D.y+B},B,z)},contains:function(z,D){var B=z.getData("dim"),C=this.getAlignedPos(z.pos.getc(true),B,B),A=B/2;this.nodeHelper.circle.contains({x:C.x+A,y:C.y+A},A)}},square:{render:function(A,z){var C=A.getData("dim"),B=C/2,D=this.getAlignedPos(A.pos.getc(true),C,C);this.nodeHelper.square.render("fill",{x:D.x+B,y:D.y+B},B,z)},contains:function(z,D){var B=z.getData("dim"),C=this.getAlignedPos(z.pos.getc(true),B,B),A=B/2;this.nodeHelper.square.contains({x:C.x+A,y:C.y+A},A)}},ellipse:{render:function(C,A){var B=C.getData("width"),z=C.getData("height"),D=this.getAlignedPos(C.pos.getc(true),B,z);this.nodeHelper.ellipse.render("fill",{x:D.x+B/2,y:D.y+z/2},B,z,A)},contains:function(B,D){var A=B.getData("width"),z=B.getData("height"),C=this.getAlignedPos(B.pos.getc(true),A,z);this.nodeHelper.ellipse.contains({x:C.x+A/2,y:C.y+z/2},A,z,canvas)}},rectangle:{render:function(C,A){var B=C.getData("width"),z=C.getData("height"),D=this.getAlignedPos(C.pos.getc(true),B,z);this.nodeHelper.rectangle.render("fill",{x:D.x+B/2,y:D.y+z/2},B,z,A)},contains:function(B,D){var A=B.getData("width"),z=B.getData("height"),C=this.getAlignedPos(B.pos.getc(true),A,z);this.nodeHelper.rectangle.contains({x:C.x+A/2,y:C.y+z/2},A,z,canvas)}}});$jit.ST.Plot.EdgeTypes=new t({none:d.empty,line:function(A,C){var B=this.getOrientation(A),D=A.nodeFrom,E=A.nodeTo,z=D._depth1&&G[0]!=B.id);this.edgeHelper.arrow(H,I,D,C,A)},"quadratic:begin":function(F,z){var E=this.getOrientation(F);var D=F.nodeFrom,G=F.nodeTo,I=D._depth0||G[ah][1]>0)){var R=L+G[ah][0],P=F+G[ah][1],ag=Math.atan((P-R)/z),Z=55;var V=N.createLinearGradient(ab+z/2,aa-(R+P)/2,ab+z/2+Z*Math.sin(ag),aa-(R+P)/2+Z*Math.cos(ag));var Q=d.rgbToHex(d.map(d.hexToRgb(J[ah%D].slice(1)),function(aj){return(aj*0.85)>>0}));V.addColorStop(0,J[ah%D]);V.addColorStop(1,Q);N.fillStyle=V}N.beginPath();N.moveTo(ab,aa-L);N.lineTo(ab+z,aa-F);N.lineTo(ab+z,aa-F-G[ah][1]);N.lineTo(ab,aa-L-G[ah][0]);N.lineTo(ab,aa-L);N.fill();N.restore();if(I){var S=I.name==M[ah];var A=S?0.7:0.8;var Q=d.rgbToHex(d.map(d.hexToRgb(J[ah%D].slice(1)),function(aj){return(aj*A)>>0}));N.strokeStyle=Q;N.lineWidth=S?4:1;N.save();N.beginPath();if(I.index===0){N.moveTo(ab,aa-L);N.lineTo(ab,aa-L-G[ah][0])}else{N.moveTo(ab+z,aa-F);N.lineTo(ab+z,aa-F-G[ah][1])}N.stroke();N.restore()}L+=(G[ah][0]||0);F+=(G[ah][1]||0);if(G[ah][0]>0){X+=(C[ah][0]||0)}}if(T&&ae.type=="Native"){N.save();N.beginPath();N.fillStyle=N.strokeStyle=ae.color;N.font=ae.style+" "+ae.size+"px "+ae.family;N.textAlign="center";N.textBaseline="middle";if(O(W.name,ad,ac,W)){N.fillText(X,ab,aa-L-Y.labelOffset-ae.size/2,z)}if(ai(W.name,ad,ac,W)){N.fillText(W.name,ab,aa+ae.size/2+Y.labelOffset)}N.restore()}}},contains:function(D,F){var K=D.pos.getc(true),A=D.getData("width"),O=D.getData("height"),N=this.getAlignedPos(K,A,O),M=N.x,L=N.y,P=D.getData("dimArray"),z=F.x-M;if(F.xM+A||F.y>L||F.y=H){var I=+(z>A/2);return{name:D.getData("stringArray")[G],color:D.getData("colorArray")[G],value:D.getData("valueArray")[G][I],index:I}}}return false}}});$jit.AreaChart=new t({st:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(B){this.controller=this.config=d.merge(p("Canvas","Label","AreaChart"),{Label:{type:"Native"}},B);var C=this.config.showLabels,A=d.type(C),D=this.config.showAggregates,z=d.type(D);this.config.showLabels=A=="function"?C:d.lambda(C);this.config.showAggregates=z=="function"?D:d.lambda(D);this.initializeViz()},initializeViz:function(){var B=this.config,E=this,z=B.type.split(":")[0],D={};var A=new $jit.ST({injectInto:B.injectInto,orientation:"bottom",levelDistance:0,siblingOffset:0,subtreeOffset:0,withLabels:B.Label.type!="Native",useCanvas:B.useCanvas,Label:{type:B.Label.type},Node:{overridable:true,type:"areachart-"+z,align:"left",width:1,height:1},Edge:{type:"none"},Tips:{enable:B.Tips.enable,type:"Native",force:true,onShow:function(I,H,F){var G=F;B.Tips.onShow(I,G,H)}},Events:{enable:true,type:"Native",onClick:function(H,I,F){if(!B.filterOnClick&&!B.Events.enable){return}var G=I.getContains();if(G){B.filterOnClick&&E.filter(G.name)}B.Events.enable&&B.Events.onClick(G,I,F)},onRightClick:function(G,H,F){if(!B.restoreOnRightClick){return}E.restore()},onMouseMove:function(H,I,F){if(!B.selectOnHover){return}if(H){var G=I.getContains();E.select(H.id,G.name,G.index)}else{E.select(false,false,false)}}},onCreateLabel:function(L,I){var R=B.Label,Q=I.getData("valueArray"),J=d.reduce(Q,function(S,T){return S+T[0]},0),O=d.reduce(Q,function(S,T){return S+T[1]},0);if(I.getData("prev")){var N={wrapper:document.createElement("div"),aggregate:document.createElement("div"),label:document.createElement("div")};var F=N.wrapper,P=N.label,G=N.aggregate,H=F.style,M=P.style,K=G.style;D[I.id]=N;F.appendChild(P);F.appendChild(G);if(!B.showLabels(I.name,J,O,I)){P.style.display="none"}if(!B.showAggregates(I.name,J,O,I)){G.style.display="none"}H.position="relative";H.overflow="visible";H.fontSize=R.size+"px";H.fontFamily=R.family;H.color=R.color;H.textAlign="center";K.position=M.position="absolute";L.style.width=I.getData("width")+"px";L.style.height=I.getData("height")+"px";P.innerHTML=I.name;L.appendChild(F)}},onPlaceLabel:function(W,Q){if(!Q.getData("prev")){return}var U=D[Q.id],G=U.wrapper.style,F=U.label.style,P=U.aggregate.style,N=Q.getData("width"),L=Q.getData("height"),K=Q.getData("dimArray"),H=Q.getData("valueArray"),M=d.reduce(H,function(X,Y){return X+Y[0]},0),I=d.reduce(H,function(X,Y){return X+Y[1]},0),J=parseInt(G.fontSize,10),O=W.style;if(K&&H){if(B.showLabels(Q.name,M,I,Q)){F.display=""}else{F.display="none"}if(B.showAggregates(Q.name,M,I,Q)){P.display=""}else{P.display="none"}G.width=P.width=F.width=W.style.width=N+"px";P.left=F.left=-N/2+"px";for(var T=0,R=H.length,S=0,V=0;T0){S+=H[T][0];V+=K[T][0]}}P.top=(-J-B.labelOffset)+"px";F.top=(B.labelOffset+V)+"px";W.style.top=parseInt(W.style.top,10)-V+"px";W.style.height=G.height=V+"px";U.aggregate.innerHTML=S}}});var C=A.canvas.getSize();A.config.offsetY=-C.height/2+B.offset+(B.showLabels&&(B.labelOffset+B.Label.size));this.st=A;this.canvas=this.st.canvas},loadJSON:function(Q){var N=d.time(),E=[],J=this.st,T=d.splat(Q.label),M=d.splat(Q.color||this.colors),R=this.config,A=!!R.type.split(":")[1],C=R.animate;for(var O=0,B=Q.values,L=B.length;O-1)?H:[0,0]}),"end")});this.st.fx.animate({modes:["node-property:dimArray"],duration:1500,onComplete:function(){B.busy=false}})},restore:function(){if(this.busy){return}this.busy=true;if(this.config.Tips.enable){this.st.tips.hide()}this.select(false,false,false);this.normalizeDims();var z=this;this.st.fx.animate({modes:["node-property:height:dimArray"],duration:1500,onComplete:function(){z.busy=false}})},select:function(E,A,z){if(!this.config.selectOnHover){return}var B=this.selected;if(B.id!=E||B.name!=A||B.index!=z){B.id=E;B.name=A;B.index=z;this.st.graph.eachNode(function(F){F.setData("border",false)});if(E){var D=this.st.graph.getNode(E);D.setData("border",B);var C=z===0?"prev":"next";C=D.getData(C);if(C){D=this.st.graph.getByName(C);if(D){D.setData("border",{name:A,index:1-z})}}}this.st.plot()}},getLegend:function(){var B={};var C;this.st.graph.getNode(this.st.root).eachAdjacency(function(D){C=D.nodeTo});var A=C.getData("colorArray"),z=A.length;d.each(C.getData("stringArray"),function(E,D){B[E]=A[D%z]});return B},getMaxValue:function(){var z=0;this.st.graph.eachNode(function(E){var B=E.getData("valueArray"),A=0,D=0;d.each(B,function(F){A+=+F[0];D+=+F[1]});var C=D>A?D:A;z=z>C?z:C});return z},normalizeDims:function(){var F=this.st.graph.getNode(this.st.root),C=0;F.eachAdjacency(function(){C++});var E=this.getMaxValue(),I=this.st.canvas.getSize(),B=this.config,D=B.offset,G=B.labelOffset+B.Label.size,z=(I.width-2*D)/C,A=B.animate,H=I.height-2*D-(B.showAggregates&&G)-(B.showLabels&&G);this.st.graph.eachNode(function(O){var L=0,N=0,J=[];d.each(O.getData("valueArray"),function(P){L+=+P[0];N+=+P[1];J.push([0,0])});var M=N>L?N:L;O.setData("width",z);if(A){O.setData("height",M*H/E,"end");O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return[P[0]*H/E,P[1]*H/E]}),"end");var K=O.getData("dimArray");if(!K){O.setData("dimArray",J)}}else{O.setData("height",M*H/E);O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return[P[0]*H/E,P[1]*H/E]}))}})}});i.Radial=new t({compute:function(A){var B=d.splat(A||["current","start","end"]);h.compute(this.graph,B,this.config);this.graph.computeLevels(this.root,0,"ignore");var z=this.createLevelDistanceFunc();this.computeAngularWidths(B);this.computePositions(B,z)},computePositions:function(G,D){var I=G;var H=this.graph;var E=H.getNode(this.root);var F=this.parent;var z=this.config;for(var B=0,A=I.length;BM[ac]?ab:M[ac]):ab}J.push(Z)},"ignore");if(F&&F.id==N.id&&J.length>0&&J[0].dist){J.sort(function(Z,Y){return(Z.dist>=Y.dist)-(Z.dist<=Y.dist)})}for(var P=0,R=J.length;P=2){return E(C-0.01)}}return E(0.75)},getRadius:function(){var z=this.config.radius;if(z!=="auto"){return z}var A=this.canvas.getSize();return Math.min(A.width,A.height)/2},refresh:function(z){if(z){this.reposition();this.graph.eachNode(function(A){A.startPos.rho=A.pos.rho=A.endPos.rho;A.startPos.theta=A.pos.theta=A.endPos.theta})}else{this.compute()}this.plot()},reposition:function(){this.compute("end");var z=this.graph.getNode(this.root).pos.getc().scale(-1);f.Util.moebiusTransformation(this.graph,[z],["end"],"end","ignore");this.graph.eachNode(function(A){if(A.ignore){A.endPos.rho=A.pos.rho;A.endPos.theta=A.pos.theta}})},plot:function(){this.fx.plot()},onClick:function(B,z){var A=this.graph.getNode(B).pos.getc(true);this.move(A,z)},move:function(D,B){var A=u(D.x,D.y);if(this.busy===false&&A.norm()<1){this.busy=true;var z=this.graph.getClosestNodeToPos(A),C=this;this.graph.computeLevels(z.id,0);this.controller.onBeforeCompute(z);B=d.merge({onComplete:d.empty},B||{});this.fx.animate(d.merge({modes:["moebius"],hideLabels:true},B,{onComplete:function(){C.busy=false;B.onComplete()}}),A)}}});$jit.Hypertree.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native,initialize:function(A){this.viz=A},renderLabel:function(C,E,B){var A=C.getCtx();var F=E.pos.getc(true);var D=this.viz.getRadius();A.fillText(E.name,F.x*D,F.y*D)}});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(L,F,G){var J=F.pos.getc(true),C=this.viz.canvas,D=C.translateOffsetX,B=C.translateOffsetY,K=C.scaleOffsetX,I=C.scaleOffsetY,H=C.getSize(),A=this.viz.getRadius();var E={x:Math.round((J.x*K)*A+D+H.width/2),y:Math.round((J.y*I)*A+B+H.height/2)};L.setAttribute("x",E.x);L.setAttribute("y",E.y);G.onPlaceLabel(L,F)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(M,G,H){var K=G.pos.getc(true),D=this.viz.canvas,E=D.translateOffsetX,C=D.translateOffsetY,L=D.scaleOffsetX,J=D.scaleOffsetY,I=D.getSize(),A=this.viz.getRadius();var F={x:Math.round((K.x*L)*A+E+I.width/2),y:Math.round((K.y*J)*A+C+I.height/2)};var B=M.style;B.left=F.x+"px";B.top=F.y+"px";B.display=this.fitsInCanvas(F,D)?"":"none";H.onPlaceLabel(M,G)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.circle.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.circle.contains(C,D,B)}},ellipse:{render:function(D,B){var E=D.pos.getc().$scale(D.scale),C=D.getData("width"),A=D.getData("height");this.nodeHelper.ellipse.render("fill",E,C,A,B)},contains:function(C,E){var B=C.getData("width"),A=C.getData("height"),D=C.pos.getc().$scale(C.scale);return this.nodeHelper.circle.contains(D,E,B,A)}},square:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.square.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.square.contains(C,D,B)}},rectangle:{render:function(E,B){var D=this.node,C=E.getData("width"),A=E.getData("height"),F=E.pos.getc();C=D.transform?C*(1-F.squaredNorm()):C;A=D.transform?A*(1-F.squaredNorm()):A;F.$scale(E.scale);if(C>0.2&&A>0.2){this.nodeHelper.rectangle.render("fill",F,C,A,B)}},contains:function(C,E){var B=C.getData("width"),A=C.getData("height"),D=C.pos.getc().$scale(C.scale);return this.nodeHelper.square.contains(D,E,B,A)}},triangle:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.triangle.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.triangle.contains(C,D,B)}},star:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.star.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.star.contains(C,D,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var E=A.nodeFrom.pos.getc(true),D=A.nodeTo.pos.getc(true),C=A.nodeFrom.scale;this.edgeHelper.line({x:E.x*C,y:E.y*C},{x:D.x*C,y:D.y*C},B)},arrow:function(B,C){var H=B.nodeFrom.pos.getc(true),G=B.nodeTo.pos.getc(true),D=B.nodeFrom.scale,F=B.getData("dim"),E=B.data.$direction,A=(E&&E.length>1&&E[0]!=B.nodeFrom.id);this.edgeHelper.arrow({x:H.x*D,y:H.y*D},{x:G.x*D,y:G.y*D},F,A,C)},hyperline:function(A,B){var E=A.nodeFrom.pos.getc(),D=A.nodeTo.pos.getc(),C=this.viz.getRadius();this.edgeHelper.hyperline(E,D,C,B)}})})($jit.Hypertree);i.TM={};i.TM.SliceAndDice=new t({compute:function(E){var A=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(A);var C=this.canvas.getSize(),B=this.config,D=C.width,z=C.height;this.graph.computeLevels(this.root,0,"ignore");A.getPos(E).setc(-D/2,-z/2);A.setData("width",D,E);A.setData("height",z+B.titleHeight,E);this.computePositions(A,A,this.layout.orientation,E);this.controller.onAfterCompute(A)},computePositions:function(I,G,S,B){var P=0;I.eachSubnode(function(U){P+=U.getData("area",B)});var T=this.config,Q=T.offset,M=I.getData("width",B),K=I.getData("height",B)-T.titleHeight,A=I==G?1:(G.getData("area",B)/P);var L,J,O,E,D,H,F;var R=(S=="h");if(R){S="v";L=K;J=M*A;O="height";E="y";D="x";H=T.titleHeight;F=0}else{S="h";L=K*A;J=M;O="width";E="x";D="y";H=0;F=T.titleHeight}var z=G.getPos(B);G.setData("width",J,B);G.setData("height",L,B);var N=0,C=this;G.eachSubnode(function(V){var U=V.getPos(B);U[E]=N+z[E]+H;U[D]=z[D]+F;C.computePositions(G,V,S,B);N+=V.getData(O,B)})}});i.TM.Area={compute:function(z){z=z||"current";var F=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(F);var B=this.config,I=this.canvas.getSize(),A=I.width,H=I.height,G=B.offset,C=A-G,E=H-G;this.graph.computeLevels(this.root,0,"ignore");F.getPos(z).setc(-A/2,-H/2);F.setData("width",A,z);F.setData("height",H,z);var D={top:-H/2+B.titleHeight,left:-A/2,width:C,height:E-B.titleHeight};this.computePositions(F,D,z);this.controller.onAfterCompute(F)},computeDim:function(D,E,G,C,B,z){if(D.length+E.length==1){var A=(D.length==1)?D:E;this.layoutLast(A,G,C,z);return}if(D.length>=2&&E.length==0){E=[D.shift()]}if(D.length==0){if(E.length>0){this.layoutRow(E,G,C,z)}return}var F=D[0];if(B(E,G)>=B([F].concat(E),G)){this.computeDim(D.slice(1),E.concat([F]),G,C,B,z)}else{var H=this.layoutRow(E,G,C,z);this.computeDim(D,[],H.dim,H,B,z)}},worstAspectRatio:function(z,H){if(!z||z.length==0){return Number.MAX_VALUE}var A=0,I=0,D=Number.MAX_VALUE;for(var F=0,E=z.length;FB?I:B}var G=H*H,C=A*A;return Math.max(G*I/C,C/(G*D))},avgAspectRatio:function(D,A){if(!D||D.length==0){return Number.MAX_VALUE}var F=0;for(var B=0,z=D.length;BC?A/C:C/A}return F/z},layoutLast:function(A,z,D,C){var B=A[0];B.getPos(C).setc(D.left,D.top);B.setData("width",D.width,C);B.setData("height",D.height,C)}};i.TM.Squarified=new t({Implements:i.TM.Area,computePositions:function(D,G,A){var C=this.config;if(!(G.width>=G.height&&this.layout.horizontal())){this.layout.change()}var z=D.getSubnodes([1,1],"ignore");if(z.length>0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;F=L._area)});var I=[z[0]];var H=z.slice(1);this.squarify(H,I,C,F,A)},squarify:function(A,D,z,C,B){this.computeDim(A,D,z,C,this.worstAspectRatio,B)},layoutRow:function(A,z,C,B){if(this.layout.horizontal()){return this.layoutV(A,z,C,B)}else{return this.layoutH(A,z,C,B)}},layoutV:function(z,K,G,A){var L=0,C=function(M){return M};d.each(z,function(M){L+=M._area});var B=C(L/K),H=0;for(var E=0,D=z.length;E0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;FI){I=L}});var B=this.graph.getNode(this.clickedNode&&this.clickedNode.id||G.id);var A=Math.min(I,F-1);var E=B._depth;if(this.layout.horizontal()){this.computeSubtree(B,-z/2,-J/2,z/(A+1),J,E,A,H)}else{this.computeSubtree(B,-z/2,-J/2,z,J/(A+1),E,A,H)}},computeSubtree:function(H,J,G,z,M,F,B,I){H.getPos(I).setc(J,G);H.setData("width",z,I);H.setData("height",M,I);var D,L=0,K=0;var A=f.Util.getSubnodes(H,[1,1]);if(!A.length){return}d.each(A,function(N){K+=N.getData("dim")});for(var E=0,C=A.length;E>0}));L.addColorStop(0,D);L.addColorStop(1,H);M.fillStyle=L}if(E){M.strokeStyle=E;M.lineWidth=3}M.fillRect(I,G,Math.max(0,z-F),Math.max(0,K-F));E&&M.strokeRect(J.x,J.y,z,K)},contains:function(B,D){if(this.viz.clickedNode&&!$jit.Graph.Util.isDescendantOf(B,this.viz.clickedNode.id)){return false}var C=B.pos.getc(true),A=B.getData("width"),z=B.getData("height");return this.nodeHelper.rectangle.contains({x:C.x+A/2,y:C.y+z/2},D,A,z)}}});$jit.Icicle.Plot.EdgeTypes=new t({none:d.empty});$jit.RGraph=new t({Implements:[e,q,i.Radial],initialize:function(z){var A=$jit.RGraph;var B={interpolation:"linear",levelDistance:100};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Controller","Tips","NodeStyles","Events","Navigation","Label"),B,z);var C=this.config;if(C.useCanvas){this.canvas=C.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(C.background){C.background=d.merge({type:"Circles"},C.background)}this.canvas=new n(this,C);this.config.labelContainer=(typeof C.injectInto=="string"?C.injectInto:C.injectInto.id)+"-label"}this.graphOptions={complex:false,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new A.Label[C.Label.type](this);this.fx=new A.Plot(this);this.op=new A.Op(this);this.json=null;this.root=null;this.busy=false;this.parent=false;this.initializeExtras()},createLevelDistanceFunc:function(){var z=this.config.levelDistance;return function(A){return(A._depth+1)*z}},refresh:function(){this.compute();this.plot()},reposition:function(){this.compute("end")},plot:function(){this.fx.plot()},getNodeAndParentAngle:function(G){var B=false;var F=this.graph.getNode(G);var D=F.getParents();var C=(D.length>0)?D[0]:false;if(C){var z=C.pos.getc(),E=F.pos.getc();var A=z.add(E.scale(-1));B=Math.atan2(A.y,A.x);if(B<0){B+=2*Math.PI}}return{parent:C,theta:B}},tagChildren:function(D,F){if(D.angleSpan){var E=[];D.eachAdjacency(function(G){E.push(G.nodeTo)},"ignore");var z=E.length;for(var C=0;C1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)}})})($jit.RGraph);i.ForceDirected=new t({getOptions:function(F){var D=this.canvas.getSize();var A=D.width,C=D.height;var E=0;this.graph.eachNode(function(H){E++});var G=A*C/E,B=Math.sqrt(G);var z=this.config.levelDistance;return{width:A,height:C,tstart:A*0.1,nodef:function(H){return G/(H||1)},edgef:function(H){return B*(H-z)}}},compute:function(A,B){var C=d.splat(A||["current","start","end"]);var z=this.getOptions();h.compute(this.graph,C,this.config);this.graph.computeLevels(this.root,0,"ignore");this.graph.eachNode(function(D){d.each(C,function(E){var F=D.getPos(E);if(F.equals(s.KER)){F.x=z.width/5*(Math.random()-0.5);F.y=z.height/5*(Math.random()-0.5)}D.disp={};d.each(C,function(G){D.disp[G]=u(0,0)})})});this.computePositions(C,z,B)},computePositions:function(D,B,E){var F=this.config.iterations,A=0,C=this;if(E){(function z(){for(var H=E.iter,G=0;G=F){E.onComplete();return}}E.onStep(Math.round(A/(F-1)*100));setTimeout(z,1)})()}else{for(;A1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)}})})($jit.ForceDirected);$jit.TM={};var y=$jit.TM;$jit.TM.$extend=true;y.Base={layout:{orientation:"h",vertical:function(){return this.orientation=="v"},horizontal:function(){return this.orientation=="h"},change:function(){this.orientation=this.vertical()?"h":"v"}},initialize:function(z){var A={orientation:"h",titleHeight:13,offset:2,levelsToShow:3,constrained:false,animate:false,Node:{type:"rectangle",overridable:true,width:3,height:3,color:"#444"},Label:{textAlign:"center",textBaseline:"top"},Edge:{type:"none"},duration:700,fps:45};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Controller","Tips","NodeStyles","Events","Navigation","Label"),A,z);this.layout.orientation=this.config.orientation;var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(B.background){B.background=d.merge({type:"Circles"},B.background)}this.canvas=new n(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={complex:true,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new y.Label[B.Label.type](this);this.fx=new y.Plot(this);this.op=new y.Op(this);this.group=new y.Group(this);this.geom=new y.Geom(this);this.clickedNode=null;this.busy=false;this.initializeExtras()},refresh:function(){if(this.busy){return}this.busy=true;var A=this;if(this.config.animate){this.compute("end");this.geom.setRightLevelToShow(this.graph.getNode(this.root));this.fx.animate(d.merge(this.config,{modes:["linear","node-property:width:height"],onComplete:function(){A.busy=false}}))}else{var z=this.config.Label.type;if(z!="Native"){var A=this;this.graph.eachNode(function(B){A.labels.hideLabel(B,false)})}this.busy=false;this.compute();this.plot()}},plot:function(){this.fx.plot()},leaf:function(z){return z.getSubnodes([1,1],"ignore").length==0},enter:function(F){if(this.busy){return}this.busy=true;var B=this,A=this.config,D=this.graph,z=F,C=this.clickedNode;var E={onComplete:function(){if(A.levelsToShow>0){B.geom.setRightLevelToShow(F)}if(A.request){B.compute()}if(A.animate){D.nodeList.setDataset(["current","end"],{alpha:[1,0]});F.eachSubgraph(function(G){G.setData("alpha",1,"end")},"ignore");B.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){B.clickedNode=z;B.compute("end");B.clickedNode=C;B.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){B.busy=false;B.clickedNode=z}})}})}else{B.busy=false;B.clickedNode=F;B.refresh()}}};if(A.request){this.requestNodes(z,E)}else{E.onComplete()}},out:function(){if(this.busy){return}this.busy=true;this.events.hoveredNode=false;var D=this,B=this.config,F=this.graph,A=F.getNode(this.clickedNode&&this.clickedNode.id||this.root).getParents(),C=A[0],z=C,E=this.clickedNode;if(!C){this.busy=false;return}callback={onComplete:function(){D.clickedNode=C;if(B.request){D.requestNodes(C,{onComplete:function(){D.compute();D.plot();D.busy=false}})}else{D.compute();D.plot();D.busy=false}}};if(B.levelsToShow>0){this.geom.setRightLevelToShow(C)}if(B.animate){this.clickedNode=z;this.compute("end");this.clickedNode=E;this.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){D.clickedNode=z;F.nodeList.setDataset(["current","end"],{alpha:[0,1]});E.eachSubgraph(function(G){G.setData("alpha",1)},"ignore");D.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){callback.onComplete()}})}})}else{callback.onComplete()}},requestNodes:function(B,C){var A=d.merge(this.controller,C),z=this.config.levelsToShow;if(A.request){var E=[],D=B._depth;B.eachLevel(0,z,function(G){var F=z-(G._depth-D);if(G.drawn&&!G.anySubnode()&&F>0){E.push(G);G._level=F}});this.group.requestNodes(E,A)}else{A.onComplete()}}};y.Op=new t({Implements:f.Op,initialize:function(z){this.viz=z}});y.Geom=new t({Implements:f.Geom,getRightLevelToShow:function(){return this.viz.config.levelsToShow},setRightLevelToShow:function(A){var B=this.getRightLevelToShow(),z=this.viz.labels;A.eachLevel(0,B+1,function(D){var C=D._depth-A._depth;if(C>B){D.drawn=false;D.exist=false;D.ignore=true;z.hideLabel(D,false)}else{D.drawn=true;D.exist=true;delete D.ignore}});A.drawn=true;delete A.ignore}});y.Group=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.config=z.config},requestNodes:function(E,D){var C=0,A=E.length,G={};var B=function(){D.onComplete()};var z=this.viz;if(A==0){B()}for(var F=0;F>0}));N.addColorStop(0,D);N.addColorStop(1,I);O.fillStyle=N}O.fillRect(J,H,z-L,M-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(J,H,z-L,M-L);O.restore()}}else{if(F>0){O.fillRect(K.x+L/2,K.y+L/2,z-L,F-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(K.x+L/2,K.y+L/2,z-L,M-L);O.restore()}}}},contains:function(C,E){if(this.viz.clickedNode&&!C.isDescendantOf(this.viz.clickedNode.id)){return false}var D=C.pos.getc(true),B=C.getData("width"),A=this.viz.leaf(C),z=A?C.getData("height"):this.config.titleHeight;return this.nodeHelper.rectangle.contains({x:D.x+B/2,y:D.y+z/2},E,B,z)}}});y.Plot.EdgeTypes=new t({none:d.empty});y.SliceAndDice=new t({Implements:[e,q,y.Base,i.TM.SliceAndDice]});y.Squarified=new t({Implements:[e,q,y.Base,i.TM.Squarified]});y.Strip=new t({Implements:[e,q,y.Base,i.TM.Strip]});p.BarChart={$extend:true,animate:true,type:"stacked",offset:25,labelOffset:3,barsOffset:0,hoveredColor:"#9fd4ff",orientation:"horizontal",showAggregates:true,showLabels:true,Tips:{enable:false,onShow:d.empty,onHide:d.empty},Events:{enable:false,onClick:d.empty}};$jit.ST.Plot.NodeTypes.implement({"barchart-stacked":{render:function(R,D){var I=R.pos.getc(true),Q=R.getData("width"),O=R.getData("height"),M=this.getAlignedPos(I,Q,O),L=M.x,K=M.y,N=R.getData("dimArray"),G=R.getData("valueArray"),F=R.getData("colorArray"),C=F.length,Y=R.getData("stringArray");var T=D.getCtx(),z={},U=R.getData("border"),A=R.getData("gradient"),aa=R.getData("config"),B=aa.orientation=="horizontal",E=aa.showAggregates,P=aa.showLabels,J=aa.Label;if(F&&N&&Y){for(var X=0,S=N.length,W=0,H=0;X>0}));Z.addColorStop(0,V);Z.addColorStop(0.5,F[X%C]);Z.addColorStop(1,V);T.fillStyle=Z}if(B){T.fillRect(L+W,K,N[X],O)}else{T.fillRect(L,K-W-N[X],Q,N[X])}if(U&&U.name==Y[X]){z.acum=W;z.dimValue=N[X]}W+=(N[X]||0);H+=(G[X]||0)}if(U){T.save();T.lineWidth=2;T.strokeStyle=U.color;if(B){T.strokeRect(L+z.acum+1,K+1,z.dimValue-2,O-2)}else{T.strokeRect(L+1,K-z.acum-z.dimValue+1,Q-2,z.dimValue-2)}T.restore()}if(J.type=="Native"){T.save();T.fillStyle=T.strokeStyle=J.color;T.font=J.style+" "+J.size+"px "+J.family;T.textBaseline="middle";if(E(R.name,H)){if(B){T.textAlign="right";T.fillText(H,L+W-aa.labelOffset,K+O/2)}else{T.textAlign="center";T.fillText(H,L+Q/2,K-O-J.size/2-aa.labelOffset)}}if(P(R.name,H,R)){if(B){T.textAlign="center";T.translate(L-aa.labelOffset-J.size/2,K+O/2);T.rotate(Math.PI/2);T.fillText(R.name,0,0)}else{T.textAlign="center";T.fillText(R.name,L+Q/2,K+J.size/2+aa.labelOffset)}}T.restore()}}},contains:function(E,G){var J=E.pos.getc(true),B=E.getData("width"),O=E.getData("height"),N=this.getAlignedPos(J,B,O),M=N.x,K=N.y,P=E.getData("dimArray"),C=E.getData("config"),A=G.x-M,z=C.orientation=="horizontal";if(z){if(G.xM+B||G.y>K+O||G.yM+B||G.y>K||G.y=I){return{name:E.getData("stringArray")[H],color:E.getData("colorArray")[H],value:E.getData("valueArray")[H]}}}}return false}},"barchart-grouped":{render:function(S,D){var J=S.pos.getc(true),R=S.getData("width"),P=S.getData("height"),N=this.getAlignedPos(J,R,P),M=N.x,L=N.y,O=S.getData("dimArray"),H=S.getData("valueArray"),Y=H.length,G=S.getData("colorArray"),C=G.length,aa=S.getData("stringArray");var U=D.getCtx(),z={},V=S.getData("border"),A=S.getData("gradient"),ac=S.getData("config"),B=ac.orientation=="horizontal",F=ac.showAggregates,Q=ac.showLabels,K=ac.Label,E=(B?P:R)/Y;if(G&&O&&aa){for(var Z=0,T=Y,X=0,I=0;Z>0}));ab.addColorStop(0,W);ab.addColorStop(0.5,G[Z%C]);ab.addColorStop(1,W);U.fillStyle=ab}if(B){U.fillRect(M,L+E*Z,O[Z],E)}else{U.fillRect(M+E*Z,L-O[Z],E,O[Z])}if(V&&V.name==aa[Z]){z.acum=E*Z;z.dimValue=O[Z]}X+=(O[Z]||0);I+=(H[Z]||0)}if(V){U.save();U.lineWidth=2;U.strokeStyle=V.color;if(B){U.strokeRect(M+1,L+z.acum+1,z.dimValue-2,E-2)}else{U.strokeRect(M+z.acum+1,L-z.dimValue+1,E-2,z.dimValue-2)}U.restore()}if(K.type=="Native"){U.save();U.fillStyle=U.strokeStyle=K.color;U.font=K.style+" "+K.size+"px "+K.family;U.textBaseline="middle";if(F(S.name,I)){if(B){U.textAlign="right";U.fillText(I,M+Math.max.apply(null,O)-ac.labelOffset,L+P/2)}else{U.textAlign="center";U.fillText(I,M+R/2,L-Math.max.apply(null,O)-K.size/2-ac.labelOffset)}}if(Q(S.name,I,S)){if(B){U.textAlign="center";U.translate(M-ac.labelOffset-K.size/2,L+P/2);U.rotate(Math.PI/2);U.fillText(S.name,0,0)}else{U.textAlign="center";U.fillText(S.name,M+R/2,L+K.size/2+ac.labelOffset)}}U.restore()}}},contains:function(K,G){var C=K.pos.getc(true),J=K.getData("width"),I=K.getData("height"),F=this.getAlignedPos(C,J,I),E=F.x,D=F.y,H=K.getData("dimArray"),N=H.length,Q=K.getData("config"),B=G.x-E,z=Q.orientation=="horizontal",A=(z?I:J)/N;if(z){if(G.xE+J||G.y>D+I||G.yE+J||G.y>D||G.y=O&&G.y<=O+A){return{name:K.getData("stringArray")[M],color:K.getData("colorArray")[M],value:K.getData("valueArray")[M]}}}else{var O=E+A*M;if(G.x>=O&&G.x<=O+A&&G.y>=D-P){return{name:K.getData("stringArray")[M],color:K.getData("colorArray")[M],value:K.getData("valueArray")[M]}}}}return false}}});$jit.BarChart=new t({st:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(B){this.controller=this.config=d.merge(p("Canvas","Label","BarChart"),{Label:{type:"Native"}},B);var C=this.config.showLabels,A=d.type(C),D=this.config.showAggregates,z=d.type(D);this.config.showLabels=A=="function"?C:d.lambda(C);this.config.showAggregates=z=="function"?D:d.lambda(D);this.initializeViz()},initializeViz:function(){var B=this.config,E=this;var z=B.type.split(":")[0],F=B.orientation=="horizontal",D={};var A=new $jit.ST({injectInto:B.injectInto,orientation:F?"left":"bottom",levelDistance:0,siblingOffset:B.barsOffset,subtreeOffset:0,withLabels:B.Label.type!="Native",useCanvas:B.useCanvas,Label:{type:B.Label.type},Node:{overridable:true,type:"barchart-"+z,align:"left",width:1,height:1},Edge:{type:"none"},Tips:{enable:B.Tips.enable,type:"Native",force:true,onShow:function(J,I,G){var H=G;B.Tips.onShow(J,H,I)}},Events:{enable:true,type:"Native",onClick:function(I,J,G){if(!B.Events.enable){return}var H=J.getContains();B.Events.onClick(H,J,G)},onMouseMove:function(I,J,G){if(!B.hoveredColor){return}if(I){var H=J.getContains();E.select(I.id,H.name,H.index)}else{E.select(false,false,false)}}},onCreateLabel:function(L,J){var R=B.Label,P=J.getData("valueArray"),O=d.reduce(P,function(S,T){return S+T},0);var N={wrapper:document.createElement("div"),aggregate:document.createElement("div"),label:document.createElement("div")};var G=N.wrapper,Q=N.label,H=N.aggregate,I=G.style,M=Q.style,K=H.style;D[J.id]=N;G.appendChild(Q);G.appendChild(H);if(!B.showLabels(J.name,O,J)){M.display="none"}if(!B.showAggregates(J.name,O,J)){K.display="none"}I.position="relative";I.overflow="visible";I.fontSize=R.size+"px";I.fontFamily=R.family;I.color=R.color;I.textAlign="center";K.position=M.position="absolute";L.style.width=J.getData("width")+"px";L.style.height=J.getData("height")+"px";K.left=M.left="0px";Q.innerHTML=J.name;L.appendChild(G)},onPlaceLabel:function(N,J){if(!D[J.id]){return}var P=D[J.id],K=P.wrapper.style,R=P.label.style,O=P.aggregate.style,S=B.type.split(":")[0]=="grouped",G=B.orientation=="horizontal",V=J.getData("dimArray"),W=J.getData("valueArray"),H=(S&&G)?Math.max.apply(null,V):J.getData("width"),U=(S&&!G)?Math.max.apply(null,V):J.getData("height"),I=parseInt(K.fontSize,10),Q=N.style;if(V&&W){K.width=O.width=R.width=N.style.width=H+"px";for(var M=0,L=W.length,T=0;M0){T+=W[M]}}if(B.showLabels(J.name,T,J)){R.display=""}else{R.display="none"}if(B.showAggregates(J.name,T,J)){O.display=""}else{O.display="none"}if(B.orientation=="horizontal"){O.textAlign="right";R.textAlign="left";R.textIndex=O.textIndent=B.labelOffset+"px";O.top=R.top=(U-I)/2+"px";N.style.height=K.height=U+"px"}else{O.top=(-I-B.labelOffset)+"px";R.top=(B.labelOffset+U)+"px";N.style.top=parseInt(N.style.top,10)-U+"px";N.style.height=K.height=U+"px"}P.aggregate.innerHTML=T}}});var C=A.canvas.getSize();if(F){A.config.offsetX=+C.width/2-B.offset-(B.showLabels&&(B.labelOffset+B.Label.size))}else{A.config.offsetY=-C.height/2+B.offset+(B.showLabels&&(B.labelOffset+B.Label.size))}this.st=A;this.canvas=this.st.canvas},loadJSON:function(N){if(this.busy){return}this.busy=true;var L=d.time(),F=[],G=this.st,Q=d.splat(N.label),K=d.splat(N.color||this.colors),O=this.config,z=!!O.type.split(":")[1],C=O.animate,B=O.orientation=="horizontal",D=this;for(var M=0,A=N.values,I=A.length;MC?A:C});return A},setBarType:function(z){this.config.type=z;this.st.config.Node.type="barchart-"+z.split(":")[0]},normalizeDims:function(){var I=this.st.graph.getNode(this.st.root),D=0;I.eachAdjacency(function(){D++});var F=this.getMaxValue(),K=this.st.canvas.getSize(),C=this.config,E=C.offset,A=C.orientation=="horizontal",z=(K[A?"height":"width"]-2*E-(D-1)*C.barsOffset)/D,B=C.animate,J=K[A?"width":"height"]-2*E-(!A&&C.showAggregates&&(C.Label.size+C.labelOffset))-(C.showLabels&&(C.Label.size+C.labelOffset)),H=A?"height":"width",G=A?"width":"height";this.st.graph.eachNode(function(O){var N=0,L=[];d.each(O.getData("valueArray"),function(P){N+=+P;L.push(0)});O.setData(H,z);if(B){O.setData(G,N*J/F,"end");O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return P*J/F}),"end");var M=O.getData("dimArray");if(!M){O.setData("dimArray",L)}}else{O.setData(G,N*J/F);O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return P*J/F}))}})}});p.PieChart={$extend:true,animate:true,offset:25,sliceOffset:0,labelOffset:3,type:"stacked",hoveredColor:"#9fd4ff",Events:{enable:false,onClick:d.empty},Tips:{enable:false,onShow:d.empty,onHide:d.empty},showLabels:true,resizeLabels:false,updateHeights:false};$jit.Sunburst=new t({Implements:[e,q,i.Radial],initialize:function(z){var B=$jit.Sunburst;var A={interpolation:"linear",levelDistance:100,Node:{type:"multipie",height:0},Edge:{type:"none"},Label:{textAlign:"start",textBaseline:"middle"}};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Tips","NodeStyles","Events","Navigation","Controller","Label"),A,z);var C=this.config;if(C.useCanvas){this.canvas=C.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(C.background){C.background=d.merge({type:"Circles"},C.background)}this.canvas=new n(this,C);this.config.labelContainer=(typeof C.injectInto=="string"?C.injectInto:C.injectInto.id)+"-label"}this.graphOptions={complex:false,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new B.Label[C.Label.type](this);this.fx=new B.Plot(this);this.op=new B.Op(this);this.json=null;this.root=null;this.rotated=null;this.busy=false;this.initializeExtras()},createLevelDistanceFunc:function(){var z=this.config.levelDistance;return function(A){return(A._depth+1)*z}},refresh:function(){this.compute();this.plot()},reposition:function(){this.compute("end")},rotate:function(B,C,A){var z=B.getPos(A.property||"current").getp(true).theta;this.rotated=B;this.rotateAngle(-z,C,A)},rotateAngle:function(B,E,A){var C=this;var z=d.merge(this.config,A||{},{modes:["polar"]});var D=A.property||(E==="animate"?"end":"current");if(E==="animate"){this.fx.animation.pause()}this.graph.eachNode(function(G){var F=G.getPos(D);F.theta+=B;if(F.theta<0){F.theta+=Math.PI*2}});if(E=="animate"){this.fx.animate(z)}else{if(E=="replot"){this.fx.plot();this.busy=false}}},plot:function(){this.fx.plot()}});$jit.Sunburst.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=A.config.Node;this.edge=A.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native,initialize:function(A){this.viz=A;this.label=A.config.Label;this.config=A.config},renderLabel:function(D,F,H){var O=F.getData("span");if(OG/2&&C.theta<3*G/2);var M=J?C.theta+G:C.theta;if(J){N-=Math.abs(Math.cos(C.theta)*B.width);L+=Math.sin(C.theta)*B.width}else{if(F.id==this.viz.root){N-=B.width/2}}}P.save();P.translate(N,L);P.rotate(M);P.fillText(F.name,0,0);P.restore()}});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(O,D,F){var K=D.pos.getc(true),N=this.viz,B=this.viz.canvas;var G=B.getSize();var C={x:Math.round(K.x+G.width/2),y:Math.round(K.y+G.height/2)};O.setAttribute("x",C.x);O.setAttribute("y",C.y);var H=O.getBBox();if(H){var M=O.getAttribute("x");var J=O.getAttribute("y");var A=D.pos.getp(true);var E=Math.PI;var I=(A.theta>E/2&&A.theta<3*E/2);if(I){O.setAttribute("x",M-H.width);O.setAttribute("y",J-H.height)}else{if(D.id==N.root){O.setAttribute("x",M-H.width/2)}}var L=I?A.theta+E:A.theta;if(D._depth){O.setAttribute("transform","rotate("+L*360/(2*E)+" "+M+" "+J+")")}}F.onPlaceLabel(O,D)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(J,D,F){var H=D.pos.clone(),B=this.viz.canvas,I=D.getData("height"),E=((I||D._depth==0)?I:this.viz.config.levelDistance)/2,G=B.getSize();H.rho+=E;H=H.getc(true);var C={x:Math.round(H.x+G.width/2),y:Math.round(H.y+G.height/2)};var A=J.style;A.left=C.x+"px";A.top=C.y+"px";A.display=this.fitsInCanvas(C,B)?"":"none";F.onPlaceLabel(J,D)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false),anglecontains:function(E,G){var D=E.getData("span")/2,B=E.pos.theta;var C=B-D,A=B+D;if(C<0){C+=Math.PI*2}var F=Math.atan2(G.y,G.x);if(F<0){F+=Math.PI*2}if(C>A){return(F>C&&F<=Math.PI*2)||FC&&F=C*F)&&(B<=(C*F+E))}return false}},"gradient-multipie":{render:function(D,A){var I=A.getCtx();var H=D.getData("height");var E=H?H:this.config.levelDistance;var B=I.createRadialGradient(0,0,D.getPos().rho,0,0,D.getPos().rho+E);var G=d.hexToRgb(D.getData("color")),F=[];d.each(G,function(J){F.push(parseInt(J*0.5,10))});var C=d.rgbToHex(F);B.addColorStop(0,C);B.addColorStop(1,D.getData("color"));I.fillStyle=B;this.nodeTypes.multipie.render.call(this,D,A)},contains:function(A,B){return this.nodeTypes.multipie.contains.call(this,A,B)}},"gradient-pie":{render:function(F,C){var A=C.getCtx();var G=A.createRadialGradient(0,0,0,0,0,F.getPos().rho);var E=d.hexToRgb(F.getData("color")),B=[];d.each(E,function(H){B.push(parseInt(H*0.5,10))});var D=d.rgbToHex(B);G.addColorStop(1,D);G.addColorStop(0,F.getData("color"));A.fillStyle=G;this.nodeTypes.pie.render.call(this,F,C)},contains:function(A,B){return this.nodeTypes.pie.contains.call(this,A,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var D=A.nodeFrom.pos.getc(true),C=A.nodeTo.pos.getc(true);this.edgeHelper.line(D,C,B)},arrow:function(B,C){var G=B.nodeFrom.pos.getc(true),F=B.nodeTo.pos.getc(true),E=B.getData("dim"),D=B.data.$direction,A=(D&&D.length>1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)},hyperline:function(A,B){var E=A.nodeFrom.pos.getc(),D=A.nodeTo.pos.getc(),C=Math.max(E.norm(),D.norm());this.edgeHelper.hyperline(E.$scale(1/C),D.$scale(1/C),C,B)}})})($jit.Sunburst);$jit.Sunburst.Plot.NodeTypes.implement({"piechart-stacked":{render:function(X,D){var W=X.pos.getp(true),F=X.getData("dimArray"),V=X.getData("valueArray"),J=X.getData("colorArray"),C=J.length,P=X.getData("stringArray"),S=X.getData("span")/2,N=X.pos.theta,I=N-S,M=N+S,U=new c;var Q=D.getCtx(),O={},L=X.getData("gradient"),G=X.getData("border"),ac=X.getData("config"),al=ac.showLabels,ab=ac.resizeLabels,ae=ac.Label;var ah=ac.sliceOffset*Math.cos((I+M)/2);var H=ac.sliceOffset*Math.sin((I+M)/2);if(J&&F&&P){for(var ai=0,af=F.length,z=0,aa=0;ai>0}),B=d.rgbToHex(Z);ag.addColorStop(0,aj);ag.addColorStop(0.5,aj);ag.addColorStop(1,B);Q.fillStyle=ag}U.rho=z+ac.sliceOffset;U.theta=I;var ak=U.getc(true);U.theta=M;var R=U.getc(true);U.rho+=E;var am=U.getc(true);U.theta=I;var T=U.getc(true);Q.beginPath();Q.arc(ah,H,z+0.01,I,M,false);Q.arc(ah,H,z+E+0.01,M,I,true);Q.fill();if(G&&G.name==P[ai]){O.acum=z;O.dimValue=F[ai];O.begin=I;O.end=M}z+=(E||0);aa+=(V[ai]||0)}if(G){Q.save();Q.globalCompositeOperation="source-over";Q.lineWidth=2;Q.strokeStyle=G.color;var ad=I>0;K=K<+ab?+ab:K;Q.font=ae.style+" "+K+"px "+ae.family;Q.textBaseline="middle";Q.textAlign="center";U.rho=z+ac.labelOffset+ac.sliceOffset;U.theta=X.pos.theta;var an=U.getc(true);Q.fillText(X.name,an.x,an.y);Q.restore()}}},contains:function(C,G){if(this.nodeTypes.none.anglecontains.call(this,C,G)){var I=Math.sqrt(G.x*G.x+G.y*G.y);var z=this.config.levelDistance,F=C._depth;var A=C.getData("config");if(I<=z*F+A.sliceOffset){var J=C.getData("dimArray");for(var E=0,D=J.length,H=A.sliceOffset;E=H&&I<=H+B){return{name:C.getData("stringArray")[E],color:C.getData("colorArray")[E],value:C.getData("valueArray")[E],label:C.name}}H+=B}}return false}return false}}});$jit.PieChart=new t({sb:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(z){this.controller=this.config=d.merge(p("Canvas","PieChart","Label"),{Label:{type:"Native"}},z);this.initializeViz()},initializeViz:function(){var A=this.config,D=this;var z=A.type.split(":")[0];var E=new $jit.Sunburst({injectInto:A.injectInto,useCanvas:A.useCanvas,withLabels:A.Label.type!="Native",Label:{type:A.Label.type},Node:{overridable:true,type:"piechart-"+z,width:1,height:1},Edge:{type:"none"},Tips:{enable:A.Tips.enable,type:"Native",force:true,onShow:function(I,H,F){var G=F;A.Tips.onShow(I,G,H)}},Events:{enable:true,type:"Native",onClick:function(H,I,F){if(!A.Events.enable){return}var G=I.getContains();A.Events.onClick(G,I,F)},onMouseMove:function(H,I,F){if(!A.hoveredColor){return}if(H){var G=I.getContains();D.select(H.id,G.name,G.index)}else{D.select(false,false,false)}}},onCreateLabel:function(I,H){var F=A.Label;if(A.showLabels){var G=I.style;G.fontSize=F.size+"px";G.fontFamily=F.family;G.color=F.color;G.textAlign="center";I.innerHTML=H.name}},onPlaceLabel:function(V,P){if(!A.showLabels){return}var J=P.pos.getp(true),M=P.getData("dimArray"),S=P.getData("span")/2,K=P.pos.theta,U=K-S,G=K+S,X=new c;var O=A.showLabels,I=A.resizeLabels,L=A.Label;if(M){for(var T=0,Q=M.length,R=0;T>0;F=F<+I?+I:F;V.style.fontSize=F+"px";X.rho=R+A.labelOffset+A.sliceOffset;X.theta=(U+G)/2;var J=X.getc(true);var H=D.canvas.getSize();var N={x:Math.round(J.x+H.width/2),y:Math.round(J.y+H.height/2)};V.style.left=N.x+"px";V.style.top=N.y+"px"}}});var C=E.canvas.getSize(),B=Math.min;E.config.levelDistance=B(C.width,C.height)/2-A.offset-A.sliceOffset;this.sb=E;this.canvas=this.sb.canvas;this.canvas.getCtx().globalCompositeOperation="lighter"},loadJSON:function(N){var L=d.time(),F=[],z=this.sb,Q=d.splat(N.label),H=Q.length,K=d.splat(N.color||this.colors),C=K.length,O=this.config,A=!!O.type.split(":")[1],D=O.animate,J=H==1;for(var M=0,B=N.values,I=B.length;MB?z:B});return z},normalizeDims:function(){var A=this.sb.graph.getNode(this.sb.root),z=0;A.eachAdjacency(function(){z++});var E=this.getMaxValue(),D=this.config,B=D.animate,C=this.sb.config.levelDistance;this.sb.graph.eachNode(function(J){var I=0,F=[];d.each(J.getData("valueArray"),function(K){I+=+K;F.push(1)});var H=(F.length==1)&&!D.updateHeights;if(B){J.setData("dimArray",d.map(J.getData("valueArray"),function(K){return H?C:(K*C/E)}),"end");var G=J.getData("dimArray");if(!G){J.setData("dimArray",F)}}else{J.setData("dimArray",d.map(J.getData("valueArray"),function(K){return H?C:(K*C/E)}))}J.setData("normalizedDim",I/E)})}})})();