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) 8.42 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.16-hf1 */ ZC.WJ.push("venn"),ZC.AAG=ZC.JM.CD({$i:function(A){this.b(A);var i=this;i.AF="venn",i.AY=new ZC.A8Z(i)},A2P:function(A){return A},MT:function(A){switch(A){case"m":return new ZC.TC(this)}},parse:function(){var A=this;A.b(),A.BE&&(A.BE.I5="remove",A.BE.R6="remove",A.BE.PX="remove")},ACN:function(){var A=this,i=A.MT("m","scale");i.BD="scale",i.K=A.K+"-scale",A.BO.push(i),A.b()}}),ZC.A8Z=ZC.LQ.CD({$i:function(A){this.b(A),this.E4=[],this.NZ=[],this.XD=[]},ACU:function(){return new ZC.Z0(this)},paint:function(){var A,i,t,n,a,e,r,C,s,o,Z=this,E=Z.A.BM("scale"),l=ZC.CY(E.GH,E.GM),h=-ZC.MAX,c=ZC.CY(3,Z.A3.length);for(A=0,i=c;A<i;A++)for(o=Z.A3[A].R,a=ZC.AO.OA(Z.A3[A].o["value-box"],Z.A3[A].o),t=0,n=o.length;t<n;t++)o[t].setup(),h=ZC.BR(h,o[t].AD),o[t].WN=ZC.AO.G5(Z.A3[A].ABV[t],a);var u=l/(4*Math.sqrt(h/Math.PI));function f(A,i){var t=ZC._a_(A[0]-i[0]),n=ZC._a_(A[1]-i[1]);return Math.sqrt(t*t+n*n)}var L,p,v,x=[],M=[],I=[],b=[],d=null;for(Z.NZ=[],A=0,i=c;A<i;A++)for(x[A]||(x[A]=[]),M[A]||(M[A]=[],I[A]=[]),Z.E4[A]||(Z.E4[A]=[]),o=Z.A3[A].R,b=Z.A3[A+1]&&A+1<3?Z.A3[A+1].R:Z.A3[0].R,t=0,n=o.length;t<n;t++){Z.NZ[t]||(Z.NZ[t]=[]),Z.XD[t]||(Z.XD[t]={}),o[t].WO=b[t].AD,0===A?(L=u*Math.sqrt(o[t].AD/Math.PI),p=u*Math.sqrt(o[t].WO/Math.PI),x[A][t]=u*ZC.AQ.A6G(o[t].AD,o[t].WO,o[t].WN),M[A][t]=o[t].iX-ZC.BR(L,p)/2,I[A][t]=o[t].iY+o[t].F/4):1===A?(x[A][t]=u*ZC.AQ.A6G(o[t].AD,o[t].WO,o[t].WN),M[A][t]=M[0][t]+x[0][t],I[A][t]=I[0][t],2===c&&(v=(M[0][t]-L-(E.GM-(M[1][t]+p)))/2,Z.A3[A-1].R[t].iX-=v,M[1][t]-=v,Z.E4[0][t].x-=v,Z.NZ[t][0][0]-=v,Z.A3[A-1].R[t].iY=E.iY+E.GH/2,I[1][t]=E.iY+E.GH/2,Z.E4[0][t].y=E.iY+E.GH/2)):2===A&&(x[A][t]=u*ZC.AQ.A6G(o[t].AD,o[t].WO,o[t].WN),r=(x[0][t]*x[0][t]-x[1][t]*x[1][t]+x[2][t]*x[2][t])/(2*x[0][t]),M[A][t]=M[0][t]+r,C=Math.sqrt(x[2][t]*x[2][t]-r*r),I[A][t]=I[0][t]-C,3===c&&(v=(M[0][t]-L-(E.GM-(M[1][t]+p)))/2,Z.A3[0].R[t].iX-=v,Z.A3[1].R[t].iX-=v,Z.E4[0][t].x-=v,Z.E4[1][t].x-=v,Z.NZ[t][0][0]-=v,M[2][t]-=v)),o[t].iX=M[A][t]+E.iX,o[t].iY=I[A][t],o[t].I=u*Math.sqrt(o[t].AD/Math.PI),o[t].F=u*Math.sqrt(o[t].AD/Math.PI),o[t].AI=u*Math.sqrt(o[t].AD/Math.PI),null===ZC._n_(d)&&(d=o[t].AD/(Math.PI*o[t].AI*o[t].AI));var X=u*Math.sqrt(o[t].AD/Math.PI),_=u*Math.sqrt(o[t].WO/Math.PI),D=X+_-x[A][t],N=(2*D*_-D*D)/(2*(X+_-D)),B=D-N;if(Z.E4[A][t]={x:M[A][t],y:I[A][t],sz:o[t].AI,r1:X,r2:_,dx1:B,dx2:N},0===A?(C=Math.sqrt(X*X-(X-N)*(X-N)),Z.NZ[t].push([M[0][t]+X-N,I[0][t]-C])):2===A&&(X=Z.E4[1][t].r1,_=Z.E4[1][t].r2,B=Z.E4[1][t].dx1,N=Z.E4[1][t].dx2,e=ZC.U5(Math.asin((I[1][t]-I[2][t])/x[1][t]))-ZC.U5(Math.acos((X-N)/X)),Z.NZ[t].push([M[1][t]-X*ZC.EF(e)-v,I[1][t]-X*ZC.EL(e)]),X=Z.E4[2][t].r1,_=Z.E4[2][t].r2,B=Z.E4[2][t].dx1,N=Z.E4[2][t].dx2,e=ZC.U5(Math.asin((I[0][t]-I[2][t])/x[2][t]))-ZC.U5(Math.acos((_-B)/_)),Z.NZ[t].push([M[0][t]+_*ZC.EF(e)-v,I[0][t]-_*ZC.EL(e)])),A===c-1)if(3===c){if(null!==ZC._n_(Z.A3[0].A9L[t]))Z.XD[t].area=Z.A3[0].A9L[t];else{var G=[-1],P=[-1];G[1]=f(Z.NZ[t][0],Z.NZ[t][2]),G[2]=f(Z.NZ[t][0],Z.NZ[t][1]),G[3]=f(Z.NZ[t][2],Z.NZ[t][1]),P[1]=Z.E4[0][t].sz,P[2]=Z.E4[1][t].sz,P[3]=Z.E4[2][t].sz;var y=.25*Math.sqrt((G[1]+G[2]+G[3])*(G[1]+G[2]-G[3])*(G[1]+G[3]-G[2])*(G[2]+G[3]-G[1]));for(s=1;s<=3;s++)y+=P[s]*P[s]*Math.asin(G[s]/(2*P[s]))-G[s]/4*Math.sqrt(4*P[s]*P[s]-G[s]*G[s]);Z.XD[t].area=d*y}Z.E4[0][t].intxy=ZC.AQ.A5L(Z.E4[0][t].x,Z.E4[0][t].y,Z.E4[1][t].x,Z.E4[1][t].y,Z.E4[0][t].r1-(Z.E4[0][t].dx1+Z.E4[0][t].dx2)/2),Z.E4[1][t].intxy=ZC.AQ.A5L(Z.E4[1][t].x,Z.E4[1][t].y,Z.E4[2][t].x,Z.E4[2][t].y,-(Z.E4[1][t].r1-(Z.E4[1][t].dx1+Z.E4[1][t].dx2)/2)),Z.E4[2][t].intxy=ZC.AQ.A5L(Z.E4[2][t].x,Z.E4[2][t].y,Z.E4[0][t].x,Z.E4[0][t].y,-(Z.E4[2][t].r1-(Z.E4[2][t].dx1+Z.E4[2][t].dx2)/2)),Z.XD[t].xy=[(Z.NZ[t][0][0]+Z.NZ[t][1][0]+Z.NZ[t][2][0])/3,(Z.NZ[t][0][1]+Z.NZ[t][1][1]+Z.NZ[t][2][1])/3]}else 2===c&&(Z.E4[0][t].intxy=ZC.AQ.A5L(Z.E4[0][t].x,Z.E4[0][t].y,Z.E4[1][t].x,Z.E4[1][t].y,Z.E4[0][t].r1-(Z.E4[0][t].dx1+Z.E4[0][t].dx2)/2),Z.E4[1][t].intxy=[-9999,-9999])}if(3===c)for(A=0,i=c;A<i;A++)for(a=ZC.AO.OA(Z.A3[A].o["value-box"],Z.A3[A].o),null!==ZC._n_(a.decimals)&&-1!==a.decimals||(a.decimals=0),t=0,n=Z.A3[A].R.length;t<n;t++)Z.XD[t].area=ZC.AO.G5(Z.XD[t].area,a);Z.b()}}),ZC.Z0=ZC.I2.CD({$i:function(A){this.b(A);var i=this;i.AF="venn",i.ABV=[],i.A9L=[],i.BO=["scale"],i.P8="bg"},U3:function(){return new ZC.A8A(this)},parse:function(){var A=this;A.BP=A.O6(),A.C2=A.BP[0],A.BX=A.BP[1],A.A0=A.BP[3],A.AE=A.BP[3],A.NS(),A.b(),A.assign_a([["join","ABV"],["share","A9L"]])},paint:function(){var A=this;A.b(),A.KH=A.CS("bl",0),A.PI(!0)}}),ZC.A8A=ZC.LM.CD({$i:function(A){this.b(A),this.WO=0,this.WN=0},KA:function(A,i,t,n){var a=this,e=null;return e=a.A.L<a.A.A.A3.length-1?a.A.A.A3[a.A.L+1]:a.A.A.A3[0],a.CA=[["%paired-plot-text",e.AK],["%paired-node-value",e.R[a.L].AD],["%joined-value",a.WN],["%shared-value",null===ZC._n_(a.A.A.XD[a.L])?0:a.A.A.XD[a.L].area]],A=a.b(A,i,t,n)},setup:function(){var A=this,i=A.C.BM("scale"),t=A.L%i.H7,n=Math.floor(A.L/i.H7);A.iX=i.iX+t*i.GM+i.GM/2+i.BK,A.iY=i.iY+n*i.GH+i.GH/2+i.BJ,A.I3||(A.copy(A.A),A.E6=A.A.E6,A.DH()&&A.parse(!1),A.I3=!0),A.I=i.GM/2,A.F=i.GH/2},AC6:function(A){var i=this,t=A.I,n=A.F,a=i.iX-t/2,e=i.iY-n/2;if(3===i.A.A.A3.length)switch(i.A.L){case 0:a-=i.AI/4,e+=i.AI/8;break;case 1:a+=i.AI/4,e+=i.AI/8;break;case 2:e-=i.AI/4}else switch(i.A.L){case 0:a-=i.AI/4;break;case 1:a+=i.AI/4}return null!==ZC._n_(A.o.x)&&(a=A.iX),null!==ZC._n_(A.o.y)&&(e=A.iY),a+=A.BK,e+=A.BJ,[ZC._i_(a),ZC._i_(e)]},H1:function(){var A,i,t=this,n=t.b(),a=t.C.K+"-value-box "+t.C.K+"-plot-"+t.A.L+"-value-box zc-value-box",e=t.G.usc()?t.G.mc("top"):t.C.AJ["3d"]||t.G.KK?ZC.AM(t.C.K+"-plots-vb-c"):ZC.AM(t.C.K+"-plot-"+t.A.L+"-vb-c"),r=t.G.usc()?ZC.AM(t.C.A.K+"-top"):ZC.AM(t.C.A.K+"-text");if(null!==ZC._n_(n.o.joined)){if(0===t.A.L&&!t.C.E["plot1.visible"]||1===t.A.L&&!t.C.E["plot2.visible"]||2===t.A.L&&!t.C.E["plot0.visible"])return;t.A.L<t.A.A.A3.length-1?t.A.A.A3[t.A.L+1]:t.A.A.A3[0],A=t.A.A.E4[t.A.L][t.L].intxy,(i=new ZC.DN(t)).copy(n),i.o.text=""+t.WN,i.append(n.o.joined),i.KA=function(A){return t.KA(A,{})},i.parse(),i.GN=a,i.K=t.K+"-value-box-join",i.Z=n.C8=e,i.IP=r,i.iX=A[0]-i.I/2,i.iY=A[1]-i.F/2,i.AP&&(i.paint(),i.EP())}if(null!==ZC._n_(n.o.shared)&&2===t.A.L){if(!t.C.E["plot0.visible"]||!t.C.E["plot1.visible"]||!t.C.E["plot2.visible"])return;A=t.A.A.XD[t.L].xy,(i=new ZC.DN(t)).copy(n),i.o.text=""+t.A.A.H3[t.A.L],i.append(n.o.shared),i.KA=function(A){return t.KA(A,{})},i.parse(),i.GN=a,i.K=t.K+"-value-box-shared",i.Z=n.C8=e,i.IP=r,i.iX=A[0]-i.I/2,i.iY=A[1]-i.F/2,i.AP&&(i.paint(),i.EP())}},ABE:function(){return{color:this.B9}},Y3:function(){return{"background-color":this.BX,"border-color":this.BX,color:this.C2}},paint:function(){var A,i=this;if(i.A.L>=3)i.A.U&&i.H1();else{i.b();var t=i.P=i.A.IJ(i,i),n=new ZC.DT(i.A);n.K=i.K,n.Z=i.A.CS("bl",1),n.C8=i.A.CS("bl",0),n.copy(t);var a=i.iX,e=i.iY;if(n.iX=a,n.iY=e,n.AI=i.AI,n.DJ="circle",n.E.plotidx=i.A.L,n.E.nodeidx=i.L,n.parse(),i.FT=n,i.A.GG&&!i.C.HM){var r=n,C={};r.iX=a,r.iY=e,C.x=a,C.y=e;var s=i.A.LE;if(r.C6=0,C.alpha=t.C6,3===s)r.AI=2,C.size=i.AI;else if(4===s){switch(i.A.L){case 0:r.iX=a-3*i.AI,r.iY=e;break;case 1:r.iX=a+3*i.AI,r.iY=e;break;case 2:r.iX=a,r.iY=e-3*i.AI}C.x=a,C.y=e}for(A in i.A.FY)r[ZC.E8.GO[ZC.EH(A)]]=i.A.FY[A],C[ZC.EH(A)]=t[ZC.E8.GO[ZC.EH(A)]];if(i.C.ER||(i.C.ER={}),null!==ZC._n_(i.C.ER[i.A.L+"-"+i.L]))for(A in i.C.ER[i.A.L+"-"+i.L])r[ZC.E8.GO[ZC.EH(A)]]=i.C.ER[i.A.L+"-"+i.L][A];i.C.ER[i.A.L+"-"+i.L]={},ZC._cp_(C,i.C.ER[i.A.L+"-"+i.L]);var o=new ZC.E8(r,C,i.A.JG,i.A.LC,ZC.E8.RQ[i.A.LF],function(){Z()});o.AW=i,i.LU(o)}else n.paint(),Z()}function Z(){var A=i.C.K+"-node-area "+i.C.K+"-plotset-plot-"+i.A.L+"-node-area zc-node-area",t=ZC.Q.FO("circle",i.A.E9,i.A.IE)+'class="'+A+'" '+i.a11y()+' id="'+i.K+'" coords="'+ZC._i_(i.iX+ZC.MAPTX)+","+ZC._i_(i.iY+ZC.MAPTX)+","+ZC._i_(ZC.BR(ZC.mobile?6:3,i.AI)*(ZC.mobile?2:1.2))+'" />';i.A.A.H3.push(t),i.A.U&&i.H1()}},A15:function(A){var i=this;ZC.move||i.MC({layer:A,type:"shape",initcb:function(){this.DJ="circle",this.A0=i.A.BP[3],this.AE=i.A.BP[3]},setupcb:function(){this.iX=i.iX,this.iY=i.iY,this.AI=i.AI}})}});