zingchart
Version:
Our JavaScript charting library is a commercial product. But the full branded version is free to try, forever.
8 lines (7 loc) • 12.4 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.16-hf1
*/
ZC.WJ.push("tooltip");var A29={$i:function(t){var A=this;A.G=t,A.VG=!1,A.OU=250,A.GK=0,A.H0=0,A.H5=20,A.BA="",A.CI=[],A.A7=null},onmouseout:function(){var t=this;ZC.mobile||(t.VG?(null!==ZC._n_(t.C4)&&window.clearInterval(t.C4),t.C4=window.setInterval(function(){var A=t.G.K,e=ZC.A4("#"+A+("svg"===t.G.AC?"-top":"-main")),o=ZC.E5[0]-e.offset().left,i=ZC.E5[1]-e.offset().top;ZC.DS(o,t.GK,t.GK+t.A7.I)&&ZC.DS(i,t.H0,t.H0+t.A7.F)||(null!==ZC._n_(t.C4)&&window.clearInterval(t.C4),t.hide())},t.OU)):t.hide())},clear:function(){var t=this;ZC.Q.IW(ZC.AM(t.G.K+"-tooltip-c"),t.G.AC,t.iX,t.iY,t.I,t.F,t.K)},hide:function(){if(!ZC.TTLOCK){var t=this.G.K;ZC.Q.EW([t+"-tooltip-text",t+"-tooltip",t+"-tooltip-text-float"]),"svg"===this.G.AC&&ZC.A4("clipPath").each(function(){-1!==this.id.indexOf("-hover_image-clip")&&ZC.Q.EW(this.id)})}},show:function(t){var A,e=this;null!==ZC._n_(e.C4)&&window.clearInterval(e.C4);var o=e.G.K;if(0!==ZC.A4("#"+o+"-tooltip-c").length&&e.A7){var i=ZC._tx_(e.G.K),l=ZC.Q.MJ(t),n=ZC.A4("#"+o+("svg"===e.G.AC?"-top":"-main")),a=null===ZC._n_(t.target)?e.A7.o.x:l[0]-n.offset().left,r=null===ZC._n_(t.target)?e.A7.o.y:l[1]-n.offset().top,p=a-e.A7.I*i[0]/2,C=r-e.A7.F*i[1],c=p,s=1+2*e.A7.JZ;if(null!==ZC._n_(e.A7.o.x)&&((p=ZC.IO(e.A7.o.x,!0))>0&&p<1&&(p=ZC._i_(e.G.I*p)),e.A7.o.fixed&&(p-=e.A7.I/2)),null!==ZC._n_(e.A7.o.y)&&((C=ZC.IO(e.A7.o.y,!0))>0&&C<1&&(C=ZC._i_(e.G.F*C)),e.A7.o.fixed&&(C-=e.A7.F/2)),p+=ZC._i_(e.A7.E["offset-x"]),C+=ZC._i_(e.A7.E["offset-y"]),"svg"===e.G.AC||!e.A7.o.placement||e.A7.o.fixed){var f=0,_=!1,Z=e.A7.EQ;p/i[0]<s&&(f=c/i[0]-s-e.A7.HD/2,p=s),p/i[0]+e.A7.I>e.G.I-s&&(f=c/i[0]+e.A7.I-e.G.I+s+e.A7.HD/2,p=(e.G.I-s-e.A7.I)*i[0]),C/i[1]<s&&(e.CI.node||!e.A7.o.placement||e.A7.o.fixed?(C=s+ZC._i_(e.A7.E["offset-y"]),C=e.CI.node?C<s?s:C:C<s?r-ZC._i_(e.A7.E["offset-y"]):C,Z="top",_=!0):C=s+(r-ZC._i_(e.A7.E["offset-y"]))),C/i[1]+e.A7.F>e.G.F-s&&(C=e.G.F-s-e.A7.F,(e.CI.node||!e.A7.o.placement||e.A7.o.fixed)&&(Z="top",_=!0)),_&&(e.A7.EQ=Z),(0!==f||_)&&e.A7.Z&&(e.clear(),""!==e.A7.AK&&(_&&(e.A7.EQ=Z),f=ZC.CY(f,e.A7.I/2-e.A7.HD/2),f=48*(f=ZC.BR(f,-e.A7.I/2+e.A7.HD/2))/(e.A7.I/2-e.A7.HD/2),e.A7.EY=f,e.A7.AP&&e.A7.paint()))}switch(e.GK=p,e.H0=C,e.G.AC){case"svg":null===ZC._n_(e.A7.o.x)&&null===ZC._n_(e.A7.o.y)&&ZC.AM(o+"-tooltip").setAttribute("transform","translate("+p/i[0]+","+C/i[1]+")"),e.A7.E["html-mode"]&&ZC.Q.OV(ZC.AM(o+"-tooltip-text-float"),{left:(""===e.BA?p/i[0]:e.A7.iX)+e.A7.EN+"px",top:(""===e.BA?C/i[1]:e.A7.iY)+e.A7.FH+"px"});break;case"vml":null===ZC._n_(e.A7.o.x)&&null===ZC._n_(e.A7.o.y)&&ZC.Q.OV(ZC.AM(o+"-tooltip"),{left:p+"px",top:C+"px"});break;case"canvas":null!==ZC._n_(e.CI.x)&&(p=e.CI.x),null!==ZC._n_(e.CI.y)&&(C=e.CI.y);var d=e.A7.E["html-mode"]?0:20;switch(e.A7.VF){case"tl":break;case"tr":p-=e.A7.I;break;case"bl":C-=e.A7.F;break;case"br":p-=e.A7.I,C-=e.A7.F;break;case"c":p-=e.A7.I/2,C-=e.A7.F/2;break;case"t":p-=e.A7.I/2;break;case"r":p-=e.A7.I,C-=e.A7.F/2;break;case"b":p-=e.A7.I/2,C-=e.A7.F;break;case"l":C-=e.A7.F/2}ZC.Q.OV(ZC.AM(o+"-tooltip-c"),{left:p/i[0]-d+"px",top:C/i[1]-d+"px"}),null!==(A=ZC.AM(o+"-tooltip-text"))&&(A.style.display="none",ZC.Q.OV(A,{width:e.A7.I+"px",height:e.A7.F+"px",left:p/i[0]+"px",top:C/i[1]+"px"}),A.style.display="block")}}},onmousemove:function(t){this.show(t)},onmouseover:function(t,A){var e,o,i,l,n,a,r,p=this,C=p.G.K,c=t.targetid||t.target.id,s=c.replace(/--([a-zA-Z0-9]+)/,"").replace("-gshape-area","-area").replace("-area-path","").replace("-path","").replace("-marker-circle","").replace("-marker","").split("-").reverse(),f=c.split("--"),_=!1,Z=!1,d=!1;if("node"===s[1]&&"plot"===s[3]&&"plotset"===s[4]&&(_=!0),ZC.Q.EW([C+"-tooltip-text",C+"-tooltip",C+"-tooltip-text-float"]),_){if(!(l=p.G.P0(s[5])))return;if(n=l.AY.A3[s[2]],a=n.FQ(s[0]),"xy"===l.AJ.layout&&a.R4(),!a)return;ZC.A4("#"+C+"-graph-"+s[5]+"-plot-"+s[2]+"-bg-hover-c").show()}else"legend"===s[2]&&0===s[1].indexOf("item")&&(Z=!0),0!==s[2].indexOf("scale")||0!==s[1].indexOf("item")&&0!==s[1].indexOf("marker")||(d=!0),l=p.G.P0(s[3]);if(ZC.AM(C+"-tooltip")||(ZC.Q.K5({id:C+"-tooltip",p:ZC.AM(C+"-main"),cls:"zc-abs zc-tooltip",wh:p.G.I+"/"+p.G.F,overflow:"hidden"},p.G.AC),ZC.Q.HL({id:C+"-tooltip-c",p:ZC.AM(C+"-tooltip"),cls:"zc-abs",tl:"-999/-999",width:140,height:60},p.G.AC)),p.A7=zingchart.pool.getInstance("DN",p,C+"-tooltip-text"),p.A7.NY="tooltip",p.A7.A=p.G,l&&l.A7&&p.A7.copy(l.A7),_)p.A7.append(n.A7.o),l.CF["p"+n.L]&&l.CF["p"+n.L]["n"+a.L]&&p.A7.append(n.A7.o["selected-state"]),2===f.length&&p.A7.append(n.AC2(f[1]));else{var x=!1;if(Z&&l.BE&&null!==ZC._n_(l.BE.o.tooltip)&&(p.A7.o.text="",p.A7.append(l.BE.o.tooltip),x=!0),d){p.A7.append({"background-color":"#fff","border-width":1,"border-color":"#999"});var u=l.BM(s[2].replace(/\_/g,"-"));if(u&&null!==ZC._n_(u.o.tooltip)&&(p.A7.o.text="",p.A7.append(u.o.tooltip),x=!0),0===s[1].indexOf("item_"))u&&(-1!==s[1].indexOf("_title")&&u.o.label&&u.o.label.tooltip?(p.A7.o.text="",p.A7.append(u.o.label.tooltip),x=!0):u.o.item&&u.o.item.tooltip&&(p.A7.o.text="",p.A7.append(u.o.item.tooltip),x=!0));else if(0===s[1].indexOf("marker_")){var I=ZC._i_(s[1].replace("marker_",""));u.Q8[I]&&u.Q8[I].o.label&&u.Q8[I].o.label.tooltip&&(p.A7.o.text="",p.A7.append(u.Q8[I].o.label.tooltip),x=!0)}}if("shape"===s[2])if(p.A7.append({"background-color":"#fff","border-width":1,"border-color":"#999"}),t.target.getAttribute("data-lowlevel"))p.A7.append({text:t.target.getAttribute("data-tooltip-text")}),x=!0;else for(o=0,i=l.FJ.length;o<i;o++)if(null!==ZC._n_(l.FJ[o])){var h=l.FJ[o]instanceof ZC.P9?l.FJ[o].BG:l.FJ[o];l.K+"-shape-"+s[1]===l.FJ[o].K&&null!==ZC._n_(e=h.o.tooltip)&&(p.A7.append(e),p.A7.o.fixed&&(p.A7.o.x=h.iX,p.A7.o.y=h.iY),x=!0)}if("label"===s[2])for(p.A7.append({"background-color":"#fff","border-width":1,"border-color":"#999"}),o=0,i=l.BY.length;o<i;o++)l.K+"-label-"+s[1]===l.BY[o].K&&null!==ZC._n_(e=l.BY[o].o.tooltip)&&(p.A7.append(e),p.A7.o.fixed&&(p.A7.o.x=l.BY[o].iX+l.BY[o].I/2,p.A7.o.y=l.BY[o].iY+l.BY[o].F/2),x=!0);if("xy"===s[2]&&(p.A7.append({"background-color":"#fff","border-width":1,"border-color":"#999"}),x=!0),!x)return}A&&p.A7.append(A),p.VG=!1,p.OU=250,null!==ZC._n_(e=p.A7.o.sticky)&&(p.VG=ZC._b_(e)),null!==ZC._n_(e=p.A7.o.timeout)&&(p.OU=ZC._i_(e)),null!==ZC._n_(e=p.A7.o.placement)?p.BA=e:p.BA="",null!==ZC._n_(e=p.A7.o.distance)&&(p.H5=ZC._i_(e)),p.A7.iX=0,p.A7.iY=0,p.A7.Z=p.A7.C8=ZC.AM(C+"-tooltip-c");var y={};if(_)r=a.Y3(),a.H8(r),null!==ZC._n_(r["line-color"])?p.A7.A0=p.A7.AE=ZC.AO.JQ(r["line-color"]):p.A7.A0=p.A7.AE=ZC.AO.JQ(r["background-color"]),p.A7.BX=r["border-color"],p.A7.C2=r.color,null!==ZC._n_(n.o.rules)?(p.A04||(p.A04=new ZC.I2(n.A),p.A04.E["quick-parse"]=!0),p.A04.append(n.o),p.A04.parse(),p.A04.IQ=function(t){return a.IQ(t)},p.A04.DH()&&p.A04.parse(),p.A7.AK=p.A04.JR):p.A7.AK=n.JR,y=ZC.AO.OA(p.A7.o,n.o),p.A7.KA=function(t){return a.KA(t,y)},p.A7.E.plotidx=a.A.L,p.A7.E.nodeidx=a.L;else if(Z){for(n=l.AY.A3[s[1].replace("item_","")],p.A7.append(n.o["legend-tooltip"]),a=null,o=0,i=n.R.length;o<i;o++)if(null!==n.R[o]){a=n.FQ(o);break}if(a){if("-1"===(r=a.Y3())["background-color"])return;p.A7.A0=p.A7.AE=ZC.AO.JQ(r["background-color"]),p.A7.C2=r.color}else p.A7.A0=p.A7.AE=ZC.AO.JQ(n.BP[1]),p.A7.C2=n.BP[0];p.A7.AK=n.P5,p.A7.KA=function(t){return t=(t=t.replace(/%plot-description/g,n.P5)).replace(/%plot-text|%t/g,n.AK)}}else if(d){if(0===s[1].indexOf("item_")){var b=s[1].replace("item_","").split("_"),m=1===b.length?ZC._i_(b[0]):ZC._i_(b[1]);p.A7.KA=function(t){t=t||"%scale-value";var A=u.BY[m]||u.V[m];if(u.F7){var e={"transform-date":!0,"transform-date-format":u.F7.o.all||u.F7.o.text||"",utc:l.UL,timezone:l.NF};A=ZC.AO.G5(A,e,p.A,!!u.F7&&u.F7)}for(var o in"number"==typeof A&&u.IU&&null!==ZC._n_(u.IU[A])&&(A=u.IU[A]),t=(t=t.replace(/%text|%item-text|%scale-value|%v/g,A)).replace(/%tooltip-text/g,u.A4X[m]||""),u.o)u.o.hasOwnProperty(o)&&"data-"===o.substring(0,5)&&(t=t.replace("%"+o,u.o[o][m]||"","g"));return t}}}else p.A7.KA=function(t){return t};if(null===ZC._n_(p.A7.o["text-alpha"])&&(p.A7.o["text-alpha"]=1),p.A7.parse(),!_&&"canvas"!==p.G.AC&&p.A7.o.fixed&&(p.A7.iX=p.A7.iX-p.A7.I/2+p.A7.BK,p.A7.iY=p.A7.iY-p.A7.F/2+p.A7.BJ),p.A7.AP){var v,g;if(p.A7.I0&&(_&&p.A7.H8(p.A7,p.A7,null,a.M2(t,!1)),p.A7.parse()),p.A7.E["html-mode"]=!1,null!==ZC._n_(e=p.A7.o["html-mode"])&&(p.A7.E["html-mode"]=ZC._b_(e)),_&&(p.A7.IQ=function(t){return a.IQ(t)},p.A7.DH()&&(y=p.A7.overrideFormat(y),p.A7.parse())),"canvas"!==p.G.AC&&"vml"!==p.G.AC||0===p.A7.AB)v=p.A7.I+p.A7.JZ,g=p.A7.F+p.A7.JZ,v+=40,g+=40,p.A7.E["offset-x"]=p.A7.BK,p.A7.E["offset-y"]=p.A7.BJ;else{var G=1.25*ZC.BR(p.A7.I,p.A7.F)+p.A7.JZ;v=G,g=G,p.A7.iX+=(G-p.A7.I)/2,p.A7.iY+=(G-p.A7.F)/2,p.A7.E["offset-x"]=-(G-p.A7.I)/2+p.A7.BK,p.A7.E["offset-y"]=-(G-p.A7.F)/2+p.A7.BJ}if(ZC.A4("#"+C+"-tooltip-c").attr("width",v).attr("height",g),"vml"===p.G.AC&&ZC.Q.OV(ZC.AM(C+"-tooltip-c"),{top:0,left:0}),p.A7.QI=p.A7.BK,p.A7.MI=p.A7.BJ,p.A7.BK=0,p.A7.BJ=0,!t.type&&_){var F=a.iX,B=a.iY,E=0,Q=0,Y={};if(Y=ZC._n_(a.A.R[a.L].E)?a.A.R[a.L].E:a.A.R[a.L],null!==ZC._n_(Y)&&(null!==ZC._n_(Y.ax)&&(F=Y.ax),null!==ZC._n_(Y.ay)&&(B=Y.ay,B+=ZC.mobile?40:20),null!==ZC._n_(Y.fx)&&(E=Y.fx),null!==ZC._n_(Y.fy)&&(Q=Y.fy)),null!==ZC._n_(a.bCXY)){var K=a.AC9();F=K[0],B=K[1]}"canvas"===p.G.AC?(null===ZC._n_(p.A7.o.x)&&(p.A7.o.x=F-p.A7.I/2+E*p.A7.I),null===ZC._n_(p.A7.o.y)&&(p.A7.o.y=B-p.A7.F/2+Q*p.A7.F)):(null===ZC._n_(p.A7.o.x)&&(p.A7.iX=F-p.A7.I/2),null===ZC._n_(p.A7.o.y)&&(p.A7.iY=B-p.A7.F/2-20))}if(_&&(p.CI=p.getPlacementInfo(a),""!==p.BA&&("canvas"!==p.G.AC?(p.A7.o.x=p.A7.iX=p.CI.x,p.A7.o.y=p.A7.iY=p.CI.y):(p.A7.o.x=p.A7.iX=0,p.A7.o.y=p.A7.iY=0),p.A7.EQ=p.CI.cp,p.A7.EY=p.CI.co)),p.A7.AP&&""!==p.A7.AK&&("canvas"===p.G.AC&&(p.A7.E["html-mode"]||(p.A7.iX=20,p.A7.iY=20)),p.A7.paint()),(t.type&&_||t.update)&&(a.AB2(),a.C.R5(!0)),t.type||"canvas"===p.G.AC)p.show(t);else if(p.A7.E["html-mode"]){var k=p.A7.iX+p.A7.EN,w=p.A7.iY+p.A7.FH;ZC.Q.OV(ZC.AM(C+"-tooltip-text-float"),{left:k+"px",top:w+"px",zIndex:zingchart.ZINDEX})}}},getPlacementInfo:function(t){var A,e=this,o={},i=e.A7.HD,l=e.A7.GA,n=e.A7.I,a=e.A7.F;if(e.A7.E["html-mode"]&&("horizontal"===e.BA||"vertical"===e.BA||"node:"===e.BA.substring(0,5))&&(e.A7.iX=-9999,e.A7.iY=-9999,e.A7.AP)){e.A7.paint();var r=ZC.A4("#"+e.G.K+"-tooltip-text-"+("canvas"===e.G.AC?"t":"float"));n=r.width()+e.A7.EN+e.A7.FM,a=r.height()+e.A7.FH+e.A7.FR,null!==ZC._n_(e.A7.o.width)&&(n=ZC._i_(e.A7.o.width)),null!==ZC._n_(e.A7.o.height)&&(a=ZC._i_(e.A7.o.height))}if("horizontal"===e.BA)t.iX+t.I/2<t.C.iX+t.C.I/2?(o.x=t.iX+0*t.I+e.H5,o.y=t.iY+0*t.F/2-a/2,o.cp="left"):(o.x=t.iX-n-e.H5,o.y=t.iY+0*t.F/2-a/2,o.cp="right"),o.y<5&&(A=5-o.y,o.co=-ZC._i_(100*A/(a-l)),o.y=5),o.y+a>e.G.F-5&&(A=e.G.F-5-o.y-a,o.co=-ZC._i_(100*A/(a-l)),o.y=e.G.F-5-a);else if("vertical"===e.BA)t.iY+t.F/2<t.C.iY+t.C.F/2?(o.y=t.iY+0*t.F+e.H5,o.x=t.iX+0*t.I/2-n/2,o.cp="top"):(o.y=t.iY-a-e.H5,o.x=t.iX+0*t.I/2-n/2,o.cp="bottom"),o.x<5&&(A=5-o.x,o.co=-ZC._i_(100*A/(e.A7.I-i)),o.x=5),o.x+n>e.G.I-5&&(A=e.G.I-5-o.x-n,o.co=-ZC._i_(100*A/(n-i)),o.x=e.G.I-5-n);else if("node:"===e.BA.substring(0,5)&&t.getTooltipPosition){switch((o=t.getTooltipPosition(e.A7,e.BA.substring(5))).node=!0,o.side=e.BA.substring(5),o.side){case"left":o.x=o.x-n+e.A7.QI,o.y=o.y-a/2+e.A7.MI;break;case"right":o.x=o.x+e.A7.QI,o.y=o.y-a/2+e.A7.MI;break;case"top":o.x=o.x-n/2+e.A7.QI,o.y=o.y-a+e.A7.MI;break;case"bottom":o.x=o.x-n/2+e.A7.QI,o.y=o.y+e.A7.MI;break;case"center":o.x=o.x-n/2+e.A7.QI,o.y=o.y-a/2+e.A7.MI}o.cp=e.A7.EQ}if(o.node){var p=0;o.y+a>e.G.F-5&&("top"===o.side||"bottom"===o.side?(o.y=o.y-a-("bottom"===o.side?0:e.A7.GA)-e.A7.MI,o.cp="bottom"):o.y=e.G.F-a-5),o.y<5&&("top"===o.side||"bottom"===o.side?(o.y=o.y+("top"===o.side?0:e.A7.GA)+a-e.A7.MI,o.cp="top"):o.y=5),o.x+n>e.G.I-5&&("left"===o.side||"right"===o.side?(o.x=o.x-n-e.A7.QI-5,o.cp="right"):(p=48*(n-e.G.I+o.x+e.A7.HD/2)/(e.A7.I/2),o.x=e.G.I-n-e.A7.QI-5),o.co=p),o.x<5&&("left"===o.side||"right"===o.side?(o.x=o.x+e.A7.I-e.A7.QI+5,o.cp="left"):(p=48*(o.x-e.A7.HD/2)/(e.A7.I/2),o.x=5),o.co=p)}return o}};ZC.A29=ZC.C5.CD(A29);