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) 7.75 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("stock"),ZC.A9U=ZC.NM.CD({$i:function(e){this.b(e);var A=this;A.AF="stock",A.AY=new ZC.A84(A),A.AJ["enable-guide"]=!0,A.AJ["enable-animation"]=!1,A.AJ["enable-scroll"]=!0,A.AJ["enable-preview"]=!0},MT:function(e,A){switch(e){case"x":var a=this.b(e,A);return a.DF=!0,a;case"y":return this.b(e,A)}}}),ZC.A84=ZC.LQ.CD({ACU:function(){return new ZC.VJ(this)}}),ZC.VJ=ZC.A2A.CD({$i:function(e){this.b(e);var A=this;A.AF="stock",A.CW="candlestick",A.MZ={size:0},A.P8="bg"},U3:function(){return new ZC.A7F(this)},parse:function(){this.b()},paint:function(){this.b(),this.paintPreview()},paintPreview:function(){var e=this,A=e.C.BM(e.BW("v")[0]),a=A.AR(A.HC);if(e.C.B7&&e.C.B7.I3&&e.QV){for(var n=e.C.N,t=e.C.B7,o=[],r=[],i=!0,s=0,l=e.R.length;s<l;s++)if(null!==ZC._n_(e.R[s])&&null!==ZC._n_(e.R[s].DU[2])){var C=A.AR(e.R[s].DU[2]);i&&(r.push([e.R[s].iX,a]),i=!1),o.push([e.R[s].iX,C]),r.push([e.R[s].iX,C])}r.length&&r.push([r[r.length-1][0],a]);var u=e.mapPointsToPreview(r),p=e.o.preview||{};if("area"===(p.type||"area")){var Z=new ZC.DT(e.A);Z.copy(e),Z.append({"background-color":e.BX,"alpha-area":.2}),Z.append(p),Z.parse(),Z.D0=!0,Z.LB=!0,Z.B1=0,Z.AU=0,Z.EU=0,Z.G3=0,Z.C6=ZC._f_(Z.o["alpha-area"]),Z.D2=[n.iX,n.iY,n.iX+n.I,n.iY+n.F],Z.K=e.K+"-area-preview",Z.Z=t.Z,Z.D=u,Z.paint()}var c=e.mapPointsToPreview(o),d=ZC.Q.EE(t.Z,e.G.AC),D=new ZC.CZ(e);D.copy(e),D.append({"line-color":e.BX,"line-width":1}),D.append(p),D.parse(),ZC.CO.paint(d,D,c,null,3)}}}),ZC.A7F=ZC.LM.CD({$i:function(e){this.b(e),this.J5=null},setup:function(){var e=this,A=e.A.AZ,a=e.A.CQ,n=[A.W,A.A1,a.W,a.A1];if(e.JS!==n&&(null!==e.BV?e.iX=A.AR(e.BV):e.iX=A.II(e.L),e.iY=a.AR(e.AD),e.E.XB=a.AR(e.AD),e.E.A9I=a.AR(e.DU[0]),e.E.AAU=a.AR(e.DU[1]),e.E.VE=a.AR(e.DU[2]),e.JS=n),(!e.I3||e.A.GZ&&e.A.MZ.size<3)&&(e.copy(e.A),e.E6=e.A.E6,e.DH()&&e.parse(!1),e.J5=new ZC.DN(e.A),e.J5.copy(e),e.DU[2]<e.AD&&(e.J5.A0=e.J5.AE=e.C2,e.J5.BX=e.B9),e.DU[2]<e.AD?(e.A.o["trend-down"]&&(e.J5.append(e.A.o["trend-down"]),e.J5.parse()),e.A.MZ.down||(e.A.MZ.down=new ZC.DN(e.A),e.A.MZ.down.copy(e.J5),e.A.MZ.size++)):e.DU[2]>e.AD?(e.A.o["trend-up"]&&(e.J5.append(e.A.o["trend-up"]),e.J5.parse()),e.A.MZ.up||(e.A.MZ.up=new ZC.DN(e.A),e.A.MZ.up.copy(e.J5),e.A.MZ.size++)):(e.A.o["trend-equal"]&&(e.J5.append(e.A.o["trend-equal"]),e.J5.parse()),e.A.MZ.equal||(e.A.MZ.equal=new ZC.DN(e.A),e.A.MZ.equal.copy(e.J5),e.A.MZ.size++)),e.I3=!0),e.A.GZ){e.DU[2]<e.AD?e.J5=e.A.MZ.down:e.DU[2]>e.AD?e.J5=e.A.MZ.up:e.J5=e.A.MZ.equal;var t=ZC.CY(e.E.XB,e.E.VE),o=ZC.BR(e.E.XB,e.E.VE)-ZC.CY(e.E.XB,e.E.VE);o<2&&(o=2),e.E.A7R=t+o/2}},KA:function(e,A,a,n){var t=this,o=t.A.MU();function r(e){return ZC.AO.G5(e,o)}return ZC._cp_(A,o),t.CA=[["%node-value-stock-open",r(t.AD)],["%open",r(t.AD)],["%v0",r(t.AD)],["%node-value-stock-high",r(t.DU[0])],["%high",r(t.DU[0])],["%v1",r(t.DU[0])],["%node-value-stock-low",r(t.DU[1])],["%low",r(t.DU[1])],["%v2",r(t.DU[1])],["%node-value-stock-close",r(t.DU[2])],["%close",r(t.DU[2])],["%v3",r(t.DU[2])]],e=t.b(e,A,a,n)},AA0:function(){var e,A,a=this;if(a.DU=[],a.o.value instanceof Array&&5===a.o.value.length)a.BV=ZC._f_(a.o.value[0]),null!==a.BV&&(null!==ZC._n_(a.A.K8[a.BV])&&-1!==ZC.AV(a.A.K8[a.BV],a.L)||a.A.V9(a.BV,a.L)),A=[a.o.value[1],a.o.value[2],a.o.value[3],a.o.value[4]];else if(a.o.value[1]instanceof Array){if("string"==typeof a.o.value[0]){var n=ZC.AV(a.A.AZ.IU,a.o.value[0]);-1!==n?a.BV=n:(a.A.AZ.IU.push(a.o.value[0]),a.BV=a.A.AZ.IU.length-1)}else a.BV=ZC._f_(a.o.value[0]);null!==a.BV&&(null!==ZC._n_(a.A.K8[a.BV])&&-1!==ZC.AV(a.A.K8[a.BV],a.L)||a.A.V9(a.BV,a.L)),A=a.o.value[1]}else A=a.o.value;a.CK=A.join(" "),a.AD=ZC._f_(A[0]),null!==ZC._n_(e=A[1])&&a.DU.push(ZC._f_(e)),null!==ZC._n_(e=A[2])&&a.DU.push(ZC._f_(e)),null!==ZC._n_(e=A[3])&&a.DU.push(ZC._f_(e))},ABE:function(){var e=this,A={};return e.DU[2]<e.AD?A["background-color"]=e.J5.B9:A["background-color"]=e.J5.A0,A.color=e.J5.C2,A},Y3:function(){var e=this,A={};return e.DU[2]<e.AD?A["background-color"]=e.J5.B9:A["background-color"]=e.J5.A0,A["border-color"]=A["background-color"],A.color=e.J5.C2,A},A8E:function(){return this.Y3()},paint:function(){var e,A=this;A.b();var a=A.A.AZ;A.setup();for(var n=a.AA*A.A.Y,t=A.A.L,o=0,r=0;r<A.A.A.K7.stock.length;r++)o++,-1!==ZC.AV(A.A.A.K7[A.A.AF][r],A.A.L)&&(t=r);var i=A.A.CH;i<=1&&(i*=n);var s=A.A.CU;s<=1&&(s*=n);var l=n-i-s,C=A.A.F5;C<=1&&(C*=l),l<1&&(l=.8*n,i=.1*n,s=.1*n);var u=l,p=A.A.F0;0!==p&&(C=0),o>1&&(p>1?u=(l-(o-1)*C+(o-1)*p)/o:p*=u=(l-(o-1)*C)/(o-(o-1)*p)),u=ZC._l_(u,1,l);var Z=A.iX-n/2+i+t*(u+C)-t*p;Z=ZC._l_(Z,A.iX-n/2+i,A.iX+n/2-s);var c,d=u,D=ZC.CY(A.E.XB,A.E.VE),v=ZC.BR(A.E.XB,A.E.VE)-ZC.CY(A.E.XB,A.E.VE);if(v<2&&(v=2),i+s===0&&(Z-=.5,d+=1),A.I=d,A.F=v,A.iX=Z,A.E.A7R=D+v/2,A.setNodeData({x:Z,y:D,w:d,h:v}),A.AP){c=ZC.Q.EE(A.G.usc()?A.G.K+"-main-c":A.G.KK?A.C.K+"-plots-bl-c":A.C.K+"-plot-"+A.A.L+"-bl-1-c",A.G.AC);var h,E=A.iX+A.I/2;A.DU[2]<A.AD&&(e=A.A.o["trend-down"])?(A.E["selected-state"]=e["selected-state"],A.E["background-state"]=e["background-state"]):A.DU[2]>A.AD&&(e=A.A.o["trend-up"])?(A.E["selected-state"]=e["selected-state"],A.E["background-state"]=e["background-state"]):A.DU[2]===A.AD&&(e=A.A.o["trend-equal"])&&(A.E["selected-state"]=e["selected-state"],A.E["background-state"]=e["background-state"]);var B=A.A.IJ(A,A.J5);switch(A.A.CW){default:var U,f;(h=[]).push([E,A.E.A9I],[E,ZC.CY(A.E.XB,A.E.VE)],null,[E,A.E.AAU],[E,ZC.BR(A.E.XB,A.E.VE)]),ZC.CO.paint(c,B,h),f=A.DU[2]<A.AD?A.A.ABI:A.DU[2]>A.AD?A.A.ACL:A.A.AB6,0!==A.A.E6.length||void 0===f||A.P.o.override||A.C.KL?(U=new ZC.HU(A.A)).copy(B):U=f,A.H8(U),U.Z=A.A.CS("bl",1),U.C8=A.A.CS("bl",0),U.K=A.K,U.iX=Z,U.iY=D,U.I=A.I,U.F=A.F,U.paint(),0!==A.A.E6.length||void 0!==f||A.P.o.override||A.C.KL||(A.DU[2]<A.AD?A.A.ABI=U:A.DU[2]>A.AD?A.A.ACL=U:A.A.AB6=U);break;case"whisker":case"ohlc":h=[];var _=Math.max(A.I/4,4);h.push([E,A.E.A9I],[E,A.E.AAU],null,[E-_,A.E.XB],[E,A.E.XB],null,[E+_,A.E.VE],[E,A.E.VE]),A.H8(B),ZC.CO.paint(c,B,h)}if(A.A.FW){var w=A.C.K+"-node-area "+A.C.K+"-plotset-plot-"+A.A.L+"-node-area zc-node-area";A.A.A.H3.push(ZC.Q.FO("rect",A.A.E9,A.A.IE)+'class="'+w+'" '+A.a11y()+' id="'+A.K+'" coords="'+ZC._i_(Z+ZC.MAPTX)+","+ZC._i_(A.E.A9I+ZC.MAPTX)+","+ZC._i_(Z+d+ZC.MAPTX)+","+ZC._i_(A.E.AAU+ZC.MAPTX)+'" />')}A.A.U&&A.A.U.AP&&A.H1()}},A15:function(){var e=this;if(!ZC.move&&e.A.IK&&e.A.AP)switch(e.b(),e.A.CW){case"candlestick":var A=new ZC.HU(e.A);A.K=e.K+"-hover",A.Z=ZC.AM(e.C.K+"-hover-c"),A.C2=e.A.BP[0],A.AE=e.A.BP[3],A.B9=e.A.BP[1],A.BX=e.A.BP[1],A.A0=e.A.BP[2],A.append(e.A.IK.o),A.Q0=!0,A.parse(),A.IQ=function(A){return e.IQ(A)},A.DH()&&A.parse(),e.DU[2]<e.AD&&(A.A0=A.AE=A.C2,A.BX=A.B9),e.DU[2]<e.AD&&e.A.o["trend-down"]?(A.append(e.A.o["trend-down"]),A.append(e.A.o["hover-state"]),e.A.o["trend-down"]["hover-state"]&&A.append(e.A.o["trend-down"]["hover-state"]),A.parse()):e.DU[2]>e.AD&&e.A.o["trend-up"]?(A.append(e.A.o["trend-up"]),A.append(e.A.o["hover-state"]),e.A.o["trend-up"]["hover-state"]&&A.append(e.A.o["trend-up"]["hover-state"]),A.parse()):e.DU[2]===e.AD&&e.A.o["trend-equal"]&&(A.append(e.A.o["trend-equal"]),A.append(e.A.o["hover-state"]),e.A.o["trend-equal"]["hover-state"]&&A.append(e.A.o["trend-equal"]["hover-state"]),A.parse()),A.iX=e.getNodeData("x"),A.iY=e.getNodeData("y"),A.I=e.getNodeData("w"),A.F=e.getNodeData("h");var a=e.C.N;A.iY<a.iY&&(A.F=A.F-(a.iY-A.iY),A.iY=a.iY),A.iY+A.F>a.iY+a.F&&(A.F=a.iY+a.F-A.iY),A.AP&&A.paint()}}});