zingchart
Version:
Our JavaScript charting library is a commercial product. But the full branded version is free to try, forever.
8 lines (7 loc) • 9.38 kB
JavaScript
/*
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
*/
ZC.WG.push("line"),ZC.A6D=ZC.NK.CC({$i:function(i){this.b(i);var e=this;e.AF="line",e.AZ=new ZC.A44(e),e.AJ["enable-guide"]=!0,e.AJ["enable-preview"]=!0,e.AJ["enable-scroll"]=!0}}),ZC.A44=ZC.LN.CC({ACU:function(){return new ZC.QU(this)}}),ZC.QU=ZC.W5.CC({$i:function(i){this.b(i);var e=this;e.AF="line",e.CW="segmented",e.Y=1,e.SM="middle",e.UZ=[],e.N4=!0,e.NE=!1},TY:function(){return new ZC.A30(this)},parse:function(){var i=this;i.BP=i.O1(),i.C2=i.BP[0],i.B7=i.BP[1],i.NQ(),i.b(),i.assign_a([["step-start","SM"],["smart-sampling","N4","b"]]),i.B0=i.C.BM(i.BW("k")[0]),i.CN=i.C.BM(i.BW("v")[0])},paint:function(){var i,e,C,A,s,n,t,p=this;p.b(),p.UZ=[];var u=p.NE;if(p.KF=p.CQ("bl",0),p.O8=ZC.Q.EC(p.CQ("bl",1),p.H.AC),!p.GV||p.C.AJ["3d"])p.PD(),p.D=null;else{p.XS(),p.C7=p.CQ("bl",0);var a=!0;(null!==ZC._n_(p.A2.o.visible)&&!ZC._b_(p.A2.o.visible)||null!==ZC._n_(p.A.o.type)&&"none"===p.A2.o.type)&&(a=!1);var h=[],l=[],r=[],Y=!0,o=0,Z=null;A=0;var X=-1,L=-1,R=p.A.A3[0].S3&&p.A.A3[0].S3.length,B=p.Y,f=p.CW;if(p.Y>1&&"spline"===f&&(f="segmented"),p.B0.EG&&p.EG){for(C=p.Y,p.N4&&(C=1),i=0,e=p.R.length;i<e;i+=C)L-i<=p.Y&&(C=ZC.BQ(1,L-i)),p.R[i]&&(p.B0.IT.length>0||ZC.DP(p.R[i].BV,p.B0.V[p.B0.W],p.B0.V[p.B0.A1])||Y&&p.R[i+C]&&p.R[i+C].BV>=p.B0.V[p.B0.W])&&(Y&&p.R[i-C]&&(-1===X&&(X=i-C),L=i-C,Y=!1,o++),-1===X&&(X=i),L=i,o++,Y=!1,A=i);o>0&&p.R[A+C]&&(-1===X&&(X=A+C),L=A+C,p.R[A+C].IY=!0)}else X=p.B0.W,L=p.LR||"log"===p.B0.BT?p.R.length:p.B0.A1;p.Y=B;var c=-1;C=p.Y,p.N4&&(C=1);var v=null,_=null,b=0,F=1;A=X,u?L-X>p.C.P.F&&(b=4/p.C.P.I*(p.CN.BD-p.CN.AY),F=ZC._f_((L-X)/(4*p.C.P.F))):L-X>p.C.P.I&&(b=4/p.C.P.F*(p.CN.BD-p.CN.AY),F=ZC._f_((L-X)/(4*p.C.P.I))),p.o["sampling-threshold"]&&(b*=Math.max(1,(L-X)/ZC._i_(p.o["sampling-threshold"])),F*=Math.max(1,(L-X)/ZC._i_(p.o["sampling-threshold"])));for(p.D=[],i=X;i<=L;i+=C){var O=!1;if(((L-X)%p.Y!=0||p.B0.EG&&p.EG)&&L-i<=p.Y&&(C=ZC.BQ(1,L-i),O=!0),p.N4&&!O&&p.R[i])if(null===ZC._n_(v))v=p.R[i].CP,A=i,_=0;else{if(Math.abs(p.R[i].CP-v)<b&&i-A<F&&(!p.EG||p.R[i].BV-_<4*p.B0.SF))continue;v=p.R[i].CP,_=p.R[i].BV,A=i}if(0,Z=p.FK(i)){switch(p.R[i].IY=!0,(p.FU||p.LR)&&Z.paint(!0),-1===c&&(c=Z.iX),f){default:h.push([Z.iX,Z.iY]);break;case"spline":u?(l.push(Z.iX),r.push(Z.iY),1===l.length&&(l.push(Z.iX),r.push(Z.iY))):(l.push(Z.iY),r.push(Z.iX),1===l.length&&(l.push(Z.iY),r.push(Z.iX)));break;case"stepped":switch(p.SM){default:(n=p.FK(i-C,0))&&(n.setup(),s=ZC.AO.JW(p.R[i-C].iX,p.R[i-C].iY,Z.iX,Z.iY),h.push(u?[Z.iX,s[1]]:[s[0],Z.iY])),h.push([Z.iX,Z.iY]),(t=p.FK(i+C,0))&&(t.setup(),s=ZC.AO.JW(Z.iX,Z.iY,p.R[i+C].iX,p.R[i+C].iY),h.push(u?[Z.iX,s[1]]:[s[0],Z.iY]));break;case"before":(n=p.FK(i-C,0))&&(n.setup(),h.push([p.R[i-C].iX,p.R[i-C].iY],[p.R[i-C].iX,Z.iY])),h.push([Z.iX,Z.iY]);break;case"after":h.push([Z.iX,Z.iY]),(t=p.FK(i+C,0))&&(t.setup(),h.push([p.R[i+C].iX,Z.iY],[p.R[i+C].iX,p.R[i+C].iY]))}break;case"jumped":(n=p.FK(i-C,0))?(n.setup(),s=ZC.AO.JW(p.R[i-C].iX,p.R[i-C].iY,Z.iX,Z.iY),h.push(u?[Z.iX,s[1]]:[s[0],Z.iY])):h.push(u?[Z.iX,Z.iY-p.B0.AB/2]:[Z.iX-p.B0.AB/2,Z.iY]),h.push([Z.iX,Z.iY]),(t=p.FK(i+C,0))?(t.setup(),s=ZC.AO.JW(Z.iX,Z.iY,p.R[i+C].iX,p.R[i+C].iY),h.push(u?[Z.iX,s[1]]:[s[0],Z.iY])):h.push(u?[Z.iX,Z.iY+p.B0.AB/2]:[Z.iX+p.B0.AB/2,Z.iY]),h.push(null)}R&&Z.N7(ZC.Q.EC(p.CQ("fl",0),p.H.AC)),(p.R5&&a||p.FU||p.U)&&Z.PF(),Z.IY=!0}else null!==ZC._n_(p.o["connect-nulls"])&&ZC._b_(p.o["connect-nulls"])||(h.push(null),l.push(null),r.push(null))}if("spline"===f){l.push(l[l.length-1]),r.push(r[r.length-1]),h=[];for(var d=1;d<l.length-1;d++){var g=[l[d-1],l[d],l[d+1],l[d+2]],E=ZC._a_(r[d+1]-r[d]);E=Math.min(E,Math.max(p.C.I,p.C.F));var W=ZC.AO.YC(p.QD,g,E);for(i=0;i<W.length;i++)null!==ZC._n_(W[i][0])&&null!==ZC._n_(W[i][1])?u?h.push([W[i][1],r[d]+(p.B0.AW?1:-1)*W[i][0]*E]):h.push([r[d]+(p.B0.AW?-1:1)*W[i][0]*E,W[i][1]]):h.push(null)}}p.D0=!1;var K=p.H.O7;if(p.H.O7=!1,p.E["fast-vector-path"]=!0,ZC.CR.setup(p.O8,p),ZC.CR.paint(p.O8,p,h),p.H.O7=K,p.C.B9&&p.C.B9.HZ&&p.QQ){var D=p.mapPointsToPreview(h,!0),Q=ZC.Q.EC(p.C.B9.Z,p.H.AC),P=new ZC.CZ(p);P.copy(p),P.K=p.K+"-preview",P.DG=p.K+"-preview",P.B1=1;var G=p.o["preview-state"];G&&(P.append(G),P.parse()),ZC.CR.paint(Q,P,D,null,3)}}}}),ZC.A30=ZC.LI.CC({setup:function(){this.T6()},ABF:function(){return{color:this.A.GV?this.A.B7:this.O.B7}},Y3:function(){return{"background-color":this.O.B7,"border-color":this.O.B7,color:this.O.C2}},getTooltipPosition:function(i,e){return this.b(i,e,this.L5.AI)},paint:function(i){var e=this;void 0===i&&(i=!1),e.b();var C=e.A.NE,A=e.A.O8,s=e.A.B0,n=e.A.R;if(e.setup(),!e.A.GV||e.C.AJ["3d"]||e.A.FU){e.O.D0=e.D0=!1,e.O.C7=e.A.CQ("bl",0);var t=[],p=e.A.CW;(e.C.OA||e.A.U4)&&"spline"===e.A.CW&&(p="segmented");var u="undefined"!=typeof e.A.GB?e.A.GB:e.A.Y,a="undefined"!=typeof e.A.HG?e.A.HG:e.A.Y,h=!0,l=!0;(null===ZC._n_(n[e.L-u])||"log"!==s.BT&&!s.EG&&e.L<=s.W)&&(h=!1);var r,Y,o,Z,X=e.A.LR?e.A.R.length:s.A1;switch((null===ZC._n_(n[e.L+a])||"log"!==s.BT&&!s.EG&&e.L>=X)&&(l=!1),p){default:h&&(e.A.FK(e.L-u,0).setup(),e.A.UT&&(r=ZC.AO.JW(e.A.R[e.L-u].iX,e.A.R[e.L-u].iY,e.A.R[e.L].iX,e.A.R[e.L].iY),t.push(r))),t.push([e.iX,e.iY]),l&&(e.A.FK(e.L+a,2).setup(),r=e.A.UT?ZC.AO.JW(e.A.R[e.L].iX,e.A.R[e.L].iY,e.A.R[e.L+a].iX,e.A.R[e.L+a].iY,e.O.C5):[n[e.L+a].iX,n[e.L+a].iY],t.push(r));break;case"spline":if(e.A.D&&(t=e.A.D),e.A.D=[],n[e.L+1]){var L=[],R=[];for(Y=-1;Y<3;Y++)n[e.L+Y]?(e.A.FK(e.L+Y,2).setup(),C?(L.push(n[e.L+Y].iX),R.push(n[e.L+Y].iY)):(L.push(n[e.L+Y].iY),R.push(n[e.L+Y].iX))):0===L.length?C?(R.push(e.iY),L.push(e.iX)):(R.push(e.iX),L.push(e.iY)):(L.push(L[L.length-1]),R.push(R[R.length-1]));var B=ZC._a_(R[2]-R[1]);B=Math.min(B,Math.max(e.C.I,e.C.F));var f=ZC.AO.YC(e.A.QD,L,B);if(e.A.UT){for(Y=0;Y<ZC._i_(f.length/2)+(1===e.O.C5?1:0);Y++)f[Y]&&(C?t.push([f[Y][1],e.iY+(s.AW?1:-1)*f[Y][0]*B]):t.push([e.iX+(s.AW?-1:1)*f[Y][0]*B,f[Y][1]]));for(Y=ZC._i_(f.length/2)-1,o=f.length;Y<o;Y++)f[Y]&&(C?e.A.D.push([f[Y][1],e.iY+(s.AW?1:-1)*f[Y][0]*B]):e.A.D.push([e.iX+(s.AW?-1:1)*f[Y][0]*B,f[Y][1]]))}else for(Y=0;Y<ZC._i_(f.length);Y++)C?t.push([f[Y][1],e.iY+(s.AW?1:-1)*f[Y][0]*B]):t.push([e.iX+(s.AW?-1:1)*f[Y][0]*B,f[Y][1]])}break;case"stepped":if(h)switch(e.A.FK(e.L-u,0).setup(),r=ZC.AO.JW(e.A.R[e.L-u].iX,e.A.R[e.L-u].iY,e.A.R[e.L].iX,e.A.R[e.L].iY),e.A.SM){default:C?t.push([n[e.L-u].iX,r[1]],[e.iX,r[1]]):t.push([r[0],n[e.L-u].iY],[r[0],e.iY]);break;case"before":t.push([e.A.R[e.L-u].iX,n[e.L-u].iY],[e.A.R[e.L-u].iX,e.iY]);break;case"after":}if(t.push([e.iX,e.iY]),l)switch(e.A.FK(e.L+a,0).setup(),r=ZC.AO.JW(e.A.R[e.L+u].iX,e.A.R[e.L+u].iY,e.A.R[e.L].iX,e.A.R[e.L].iY),e.A.SM){default:t.push(C?[e.iX,r[1]]:[r[0],e.iY]);break;case"before":break;case"after":t.push([e.A.R[e.L+u].iX,e.iY],[e.A.R[e.L+u].iX,n[e.L+a].iY])}break;case"jumped":h?(e.A.FK(e.L-u,0).setup(),r=ZC.AO.JW(e.A.R[e.L-u].iX,e.A.R[e.L-u].iY,e.A.R[e.L].iX,e.A.R[e.L].iY),t.push(C?[e.iX,r[1]]:[r[0],e.iY])):t.push(C?[e.iX,e.iY-s.AB/2]:[e.iX-s.AB/2,e.iY]),t.push([e.iX,e.iY]),l?(e.A.FK(e.L+a,0).setup(),r=ZC.AO.JW(e.A.R[e.L+u].iX,e.A.R[e.L+u].iY,e.A.R[e.L].iX,e.A.R[e.L].iY),t.push(C?[e.iX,r[1]]:[r[0],e.iY])):t.push(C?[e.iX,e.iY+s.AB/2]:[e.iX+s.AB/2,e.iY])}if(e.setNodeData({points:t}),"ready"!==e.C.MD&&(e.A.UZ=e.A.UZ.concat(t)),!i&&!e.C.AJ["3d"]){var c=e.O=e.A.IG(e,e.O),v=e.C.K+"-node-area "+e.C.K+"-plotset-plot-"+e.A.L+"-node-area zc-node-area";if(c.DG=v,c.K=e.K,e.A.HW&&e.H4(c),ZC.CR.setup(A,c),e.paintPreview(c,t),e.A.GE&&!e.C.HI){var _=new ZC.DQ(e),b={};_.copy(c),_.K=e.K,_.Z=e.A.CQ("bl",1),_.C7=e.A.CQ("bl",0),_.D=t,b.points=t;var F=[],O=e.A.LA,d=e.C.P;for(_.C5=0,b.alpha=c.C5,Y=0;Y<t.length;Y++)2===O?F[Y]=[t[Y][0],d.iY+d.F/2]:3===O?F[Y]=[t[Y][0],d.iY-5]:4===O?F[Y]=[t[Y][0],d.iY+d.F+5]:5===O?F[Y]=[d.iX-5,t[Y][1]]:6===O?F[Y]=[d.iX+d.I+5,t[Y][1]]:7===O?F[Y]=[d.iX+d.I/2,t[Y][1]]:8===O?F[Y]=[t[Y][0]-d.I,t[Y][1]]:9===O?F[Y]=[t[Y][0]+d.I,t[Y][1]]:10===O?F[Y]=[t[Y][0],t[Y][1]-d.F]:11===O?F[Y]=[t[Y][0],t[Y][1]+d.F]:12===O?F[Y]=[(t[0][0]+t[t.length-1][0])/2,t[0][1]]:13===O&&(F[Y]=[t[0][0],(t[0][1]+t[t.length-1][1])/2]),O>1&&(_.D=F,b.points=t);for(Z in e.A.FY)_[ZC.E6.GM[ZC.EF(Z)]]=e.A.FY[Z],b[ZC.EF(Z)]=c[ZC.E6.GM[ZC.EF(Z)]];if(e.C.EO||(e.C.EO={}),null!==ZC._n_(e.C.EO[e.A.L+"-"+e.L]))for(Z in e.C.EO[e.A.L+"-"+e.L])_[ZC.E6.GM[ZC.EF(Z)]]=e.C.EO[e.A.L+"-"+e.L][Z];e.C.EO[e.A.L+"-"+e.L]={},ZC._cp_(b,e.C.EO[e.A.L+"-"+e.L]);var g=new ZC.E6(_,b,e.A.JG,e.A.L8,ZC.E6.RL[e.A.LB],function(){E()});g.AX=e,g.OC=function(){e.N7(ZC.Q.EC(e.A.CQ("bl",1),e.H.AC))},g.HU=A,e.LS(g)}else ZC.CR.paint(A,c,t),E()}}function E(){!e.C.OA&&ZC.DP(e.iX,s.iX-1,s.iX+s.I+1)&&ZC.DP(e.iY,s.iY-1,s.iY+s.F+1)&&(e.PF(),e.N7(ZC.Q.EC(e.A.CQ("bl",1),e.H.AC)),e.A.U&&e.A.U.AN&&e.A.E.vboxid!==e.K&&e.GY())}},paintPreview:function(i,e){var C=this;if(C.C.B9&&C.C.B9.HZ&&C.A.QQ){var A,s=C.A.mapPointsToPreview(e);C.A.VU?A=C.A.VU:(A=new ZC.CZ(C),C.A.VU=A),A.copy(i),A.K=C.K+"-line-preview",A.DG=C.A.K+"-preview";var n=ZC.Q.EC(C.C.B9.Z,C.H.AC);A.B1=1;var t=C.o["preview-state"];t&&(A.append(t),A.parse()),ZC.CR.paint(n,A,s,null,3)}},A12:function(i){var e=this;ZC.move||(e.A1W(i),e.A.R5&&e.TZ(i))}});