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.2 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("tooltip");var A29={$i:function(t){var A=this;A.H=t,A.VC=!1,A.OQ=250,A.GI=0,A.IJ=0,A.H1=20,A.BA="",A.CH=[],A.A7=null},onmouseout:function(){var t=this;ZC.mobile||(t.VC?(null!==ZC._n_(t.C4)&&window.clearInterval(t.C4),t.C4=window.setInterval(function(){var A=t.H.K,e=ZC.A5("#"+A+("svg"===t.H.AC?"-top":"-main")),o=ZC.E2[0]-e.offset().left,i=ZC.E2[1]-e.offset().top;ZC.DP(o,t.GI,t.GI+t.A7.I)&&ZC.DP(i,t.IJ,t.IJ+t.A7.F)||(null!==ZC._n_(t.C4)&&window.clearInterval(t.C4),t.hide())},t.OQ)):t.hide())},clear:function(){var t=this;ZC.Q.IV(ZC.AL(t.H.K+"-tooltip-c"),t.H.AC,t.iX,t.iY,t.I,t.F,t.K)},hide:function(){if(!ZC.TTLOCK){var t=this.H.K;ZC.Q.EV([t+"-tooltip-text",t+"-tooltip",t+"-tooltip-text-float"]),"svg"===this.H.AC&&ZC.A5("clipPath").each(function(){-1!==this.id.indexOf("-hover_image-clip")&&ZC.Q.EV(this.id)})}},show:function(t){var A,e=this;null!==ZC._n_(e.C4)&&window.clearInterval(e.C4);var o=e.H.K;if(0!==ZC.A5("#"+o+"-tooltip-c").length&&e.A7){var i=ZC._tx_(e.H.K),l=ZC.Q.MH(t),n=ZC.A5("#"+o+("svg"===e.H.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.JU;if(null!==ZC._n_(e.A7.o.x)&&((p=ZC.IL(e.A7.o.x,!0))>0&&p<1&&(p=ZC._i_(e.H.I*p)),e.A7.o.fixed&&(p-=e.A7.I/2)),null!==ZC._n_(e.A7.o.y)&&((C=ZC.IL(e.A7.o.y,!0))>0&&C<1&&(C=ZC._i_(e.H.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.H.AC||!e.A7.o.placement||e.A7.o.fixed){var f=0,d=!1,_=e.A7.EN;p/i[0]<s&&(f=c/i[0]-s-e.A7.HA/2,p=s),p/i[0]+e.A7.I>e.H.I-s&&(f=c/i[0]+e.A7.I-e.H.I+s+e.A7.HA/2,p=(e.H.I-s-e.A7.I)*i[0]),C/i[1]<s&&(e.CH.node||!e.A7.o.placement||e.A7.o.fixed?(C=s+ZC._i_(e.A7.E["offset-y"]),C=e.CH.node?C<s?s:C:C<s?r-ZC._i_(e.A7.E["offset-y"]):C,_="top",d=!0):C=s+(r-ZC._i_(e.A7.E["offset-y"]))),C/i[1]+e.A7.F>e.H.F-s&&(C=e.H.F-s-e.A7.F,(e.CH.node||!e.A7.o.placement||e.A7.o.fixed)&&(_="top",d=!0)),d&&(e.A7.EN=_),(0!==f||d)&&e.A7.Z&&(e.clear(),""!==e.A7.AM&&(d&&(e.A7.EN=_),f=ZC.CY(f,e.A7.I/2-e.A7.HA/2),f=48*(f=ZC.BQ(f,-e.A7.I/2+e.A7.HA/2))/(e.A7.I/2-e.A7.HA/2),e.A7.EX=f,e.A7.AN&&e.A7.paint()))}switch(e.GI=p,e.IJ=C,e.H.AC){case"svg":null===ZC._n_(e.A7.o.x)&&null===ZC._n_(e.A7.o.y)&&ZC.AL(o+"-tooltip").setAttribute("transform","translate("+p/i[0]+","+C/i[1]+")"),e.A7.E["html-mode"]&&ZC.Q.PL(ZC.AL(o+"-tooltip-text-float"),{left:(""===e.BA?p/i[0]:e.A7.iX)+e.A7.EQ+"px",top:(""===e.BA?C/i[1]:e.A7.iY)+e.A7.FM+"px"});break;case"vml":null===ZC._n_(e.A7.o.x)&&null===ZC._n_(e.A7.o.y)&&ZC.Q.PL(ZC.AL(o+"-tooltip"),{left:p+"px",top:C+"px"});break;case"canvas":null!==ZC._n_(e.CH.x)&&(p=e.CH.x),null!==ZC._n_(e.CH.y)&&(C=e.CH.y);var Z=e.A7.E["html-mode"]?0:20;switch(e.A7.VB){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.PL(ZC.AL(o+"-tooltip-c"),{left:p/i[0]-Z+"px",top:C/i[1]-Z+"px"}),null!==(A=ZC.AL(o+"-tooltip-text"))&&(A.style.display="none",ZC.Q.PL(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.H.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("--"),d=!1,_=!1,Z=!1;if("node"===s[1]&&"plot"===s[3]&&"plotset"===s[4]&&(d=!0),ZC.Q.EV([C+"-tooltip-text",C+"-tooltip",C+"-tooltip-text-float"]),d){if(!(l=p.H.OV(s[5])))return;if(n=l.AZ.A3[s[2]],a=n.FK(s[0]),"xy"===l.AJ.layout&&a.T6(),!a)return;ZC.A5("#"+C+"-graph-"+s[5]+"-plot-"+s[2]+"-bg-hover-c").show()}else"legend"===s[2]&&0===s[1].indexOf("item")&&(_=!0),0!==s[2].indexOf("scale")||0!==s[1].indexOf("item")&&0!==s[1].indexOf("marker")||(Z=!0),l=p.H.OV(s[3]);if(ZC.AL(C+"-tooltip")||(ZC.Q.K1({id:C+"-tooltip",p:ZC.AL(C+"-main"),cls:"zc-abs zc-tooltip",wh:p.H.I+"/"+p.H.F,overflow:"hidden"},p.H.AC),ZC.Q.HH({id:C+"-tooltip-c",p:ZC.AL(C+"-tooltip"),cls:"zc-abs",tl:"-999/-999",width:140,height:60},p.H.AC)),p.A7=zingchart.pool.getInstance("DN",p,C+"-tooltip-text"),p.A7.OE="tooltip",p.A7.A=p.H,l&&l.A7&&p.A7.copy(l.A7),d)p.A7.append(n.A7.o),l.CD["p"+n.L]&&l.CD["p"+n.L]["n"+a.L]&&p.A7.append(n.A7.o["selected-state"]),2===f.length&&p.A7.append(n.AC3(f[1]));else{var x=!1;if(_&&l.BE&&null!==ZC._n_(l.BE.o.tooltip)&&(p.A7.o.text="",p.A7.append(l.BE.o.tooltip),x=!0),Z){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 H=ZC._i_(s[1].replace("marker_",""));u.Q2[H]&&u.Q2[H].o.label&&u.Q2[H].o.label.tooltip&&(p.A7.o.text="",p.A7.append(u.Q2[H].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.FH.length;o<i;o++)if(null!==ZC._n_(l.FH[o])){var h=l.FH[o]instanceof ZC.P4?l.FH[o].BG:l.FH[o];l.K+"-shape-"+s[1]===l.FH[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.VC=!1,p.OQ=250,null!==ZC._n_(e=p.A7.o.sticky)&&(p.VC=ZC._b_(e)),null!==ZC._n_(e=p.A7.o.timeout)&&(p.OQ=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.H1=ZC._i_(e)),p.A7.iX=0,p.A7.iY=0,p.A7.Z=p.A7.C7=ZC.AL(C+"-tooltip-c");var I={};if(d)r=a.Y3(),a.H4(r),null!==ZC._n_(r["line-color"])?p.A7.A0=p.A7.AE=ZC.AQ.JO(r["line-color"]):p.A7.A0=p.A7.AE=ZC.AQ.JO(r["background-color"]),p.A7.BX=r["border-color"],p.A7.C2=r.color,null!==ZC._n_(n.o.rules)?(p.A01||(p.A01=new ZC.HY(n.A),p.A01.E["quick-parse"]=!0),p.A01.append(n.o),p.A01.parse(),p.A01.J5=function(t){return a.J5(t)},p.A01.DF()&&p.A01.parse(),p.A7.AM=p.A01.J7):p.A7.AM=n.J7,I=ZC.AQ.O5(p.A7.o,n.o),p.A7.JX=function(t){return a.JX(t,I)},p.A7.E.plotidx=a.A.L,p.A7.E.nodeidx=a.L;else if(_){for(n=l.AZ.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.FK(o);break}if(a){if("-1"===(r=a.Y3())["background-color"])return;p.A7.A0=p.A7.AE=ZC.AQ.JO(r["background-color"]),p.A7.C2=r.color}else p.A7.A0=p.A7.AE=ZC.AQ.JO(n.BP[1]),p.A7.C2=n.BP[0];p.A7.AM=n.P0,p.A7.JX=function(t){return t=(t=t.replace(/%plot-description/g,n.P0)).replace(/%plot-text|%t/g,n.AM)}}else if(Z){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.JX=function(t){t=t||"%scale-value";var A=u.BY[m]||u.V[m];if(u.F6){var e={"transform-date":!0,"transform-date-format":u.F6.o.all||u.F6.o.text||"",utc:l.UF,timezone:l.NC};A=ZC.AQ.G4(A,e,p.A,!!u.F6&&u.F6)}for(var o in"number"==typeof A&&u.IT&&null!==ZC._n_(u.IT[A])&&(A=u.IT[A]),t=(t=t.replace(/%text|%item-text|%scale-value|%v/g,A)).replace(/%tooltip-text/g,u.A4W[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.JX=function(t){return t};if(null===ZC._n_(p.A7.o["text-alpha"])&&(p.A7.o["text-alpha"]=1),p.A7.parse(),!d&&"canvas"!==p.H.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.BI),p.A7.AN){var y,v;if(p.A7.HW&&(d&&p.A7.H4(p.A7,p.A7,null,a.M0(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)),d&&(p.A7.J5=function(t){return a.J5(t)},p.A7.DF()&&(I=p.A7.overrideFormat(I),p.A7.parse())),"canvas"!==p.H.AC&&"vml"!==p.H.AC||0===p.A7.AA)y=p.A7.I+p.A7.JU,v=p.A7.F+p.A7.JU,y+=40,v+=40,p.A7.E["offset-x"]=p.A7.BK,p.A7.E["offset-y"]=p.A7.BI;else{var g=1.25*ZC.BQ(p.A7.I,p.A7.F)+p.A7.JU;y=g,v=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.BI}if(ZC.A5("#"+C+"-tooltip-c").attr("width",y).attr("height",v),"vml"===p.H.AC&&ZC.Q.PL(ZC.AL(C+"-tooltip-c"),{top:0,left:0}),p.A7.QC=p.A7.BK,p.A7.MG=p.A7.BI,p.A7.BK=0,p.A7.BI=0,!t.type&&d){var F=a.iX,B=a.iY;if(null!==ZC._n_(a.bCXY)){var E=a.ACA();F=E[0],B=E[1]}"canvas"===p.H.AC?(null===ZC._n_(p.A7.o.x)&&(p.A7.o.x=F-p.A7.I/2),null===ZC._n_(p.A7.o.y)&&(p.A7.o.y=B-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-20))}if(d&&(p.CH=p.getPlacementInfo(a),""!==p.BA&&("canvas"!==p.H.AC?(p.A7.o.x=p.A7.iX=p.CH.x,p.A7.o.y=p.A7.iY=p.CH.y):(p.A7.o.x=p.A7.iX=0,p.A7.o.y=p.A7.iY=0),p.A7.EN=p.CH.cp,p.A7.EX=p.CH.co)),p.A7.AN&&""!==p.A7.AM&&("canvas"===p.H.AC&&(p.A7.E["html-mode"]||(p.A7.iX=20,p.A7.iY=20)),p.A7.paint()),(t.type&&d||t.update)&&(a.AB3(),a.C.QZ(!0)),t.type||"canvas"===p.H.AC)p.show(t);else if(p.A7.E["html-mode"]){var Q=p.A7.iX+p.A7.EQ,Y=p.A7.iY+p.A7.FM;ZC.Q.PL(ZC.AL(C+"-tooltip-text-float"),{left:Q+"px",top:Y+"px",zIndex:zingchart.ZINDEX})}}},getPlacementInfo:function(t){var A,e=this,o={},i=e.A7.HA,l=e.A7.G9,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.AN)){e.A7.paint();var r=ZC.A5("#"+e.H.K+"-tooltip-text-"+("canvas"===e.H.AC?"t":"float"));n=r.width()+e.A7.EQ+e.A7.FN,a=r.height()+e.A7.FM+e.A7.FW,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.H1,o.y=t.iY+0*t.F/2-a/2,o.cp="left"):(o.x=t.iX-n-e.H1,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.H.F-5&&(A=e.H.F-5-o.y-a,o.co=-ZC._i_(100*A/(a-l)),o.y=e.H.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.H1,o.x=t.iX+0*t.I/2-n/2,o.cp="top"):(o.y=t.iY-a-e.H1,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.H.I-5&&(A=e.H.I-5-o.x-n,o.co=-ZC._i_(100*A/(n-i)),o.x=e.H.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.QC,o.y=o.y-a/2+e.A7.MG;break;case"right":o.x=o.x+e.A7.QC,o.y=o.y-a/2+e.A7.MG;break;case"top":o.x=o.x-n/2+e.A7.QC,o.y=o.y-a+e.A7.MG;break;case"bottom":o.x=o.x-n/2+e.A7.QC,o.y=o.y+e.A7.MG;break;case"center":o.x=o.x-n/2+e.A7.QC,o.y=o.y-a/2+e.A7.MG}o.cp=e.A7.EN}if(o.node){var p=0;o.y+a>e.H.F-5&&("top"===o.side||"bottom"===o.side?(o.y=o.y-a-("bottom"===o.side?0:e.A7.G9)-e.A7.MG,o.cp="bottom"):o.y=e.H.F-a-5),o.y<5&&("top"===o.side||"bottom"===o.side?(o.y=o.y+("top"===o.side?0:e.A7.G9)+a-e.A7.MG,o.cp="top"):o.y=5),o.x+n>e.H.I-5&&("left"===o.side||"right"===o.side?(o.x=o.x-n-e.A7.QC-5,o.cp="right"):(p=48*(n-e.H.I+o.x+e.A7.HA/2)/(e.A7.I/2),o.x=e.H.I-n-e.A7.QC-5),o.co=p),o.x<5&&("left"===o.side||"right"===o.side?(o.x=o.x+e.A7.I-e.A7.QC+5,o.cp="left"):(p=48*(o.x-e.A7.HA/2)/(e.A7.I/2),o.x=5),o.co=p)}return o}};ZC.A29=ZC.C9.CC(A29);