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) 4.61 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 */ zingchart.setModule("bubble-legend"),zingchart.plugins.bubblelegend={},zingchart.plugins.bubblelegend.info={},zingchart.bind(null,"complete",function(e){var n=zingchart.getLoader(e.id),i=zingchart.getModules(n);if(-1!==ZC.AV(i,"bubble-legend"))for(var a=0,t=n.AG.length;a<t;a++){var l=!1,r={},o=n.AG[a];if(o.o["bubble-legend"])for(var d=0,g=o.AY.A3.length;d<g;d++){var b=o.AY.A3[d];"bubble"!==b.AF&&"hbubble"!==b.AF||(l=!0,r["g"+b.A1E]=r["g"+b.A1E]||{min:Number.MAX_VALUE,max:-Number.MAX_VALUE,maxSize:0,graphid:a,plotindex:b.L,color:"-1"!==b.A2.A0?b.A2.A0:b.BP[1]},r["g"+b.A1E].max=Math.max(r["g"+b.A1E].max,b.RS),r["g"+b.A1E].min=Math.min(r["g"+b.A1E].min,b.O0))}if(l){var c=o.o["bubble-legend"]||{},h=c.layout||"v";null===ZC._n_(c.margin)&&(c.margin="v"===h?"auto 10 auto auto":"auto auto 10 auto");var p,u,s,x,z,m,_,f=[],A=0,v=Number.MAX_VALUE,y=0,C=0,Z=zingchart.getInstance(o,"textbox");for(u in r)for(y++,s=r[u],z=(x=ZC.AQ.WI(s.min,s.max))[3],A=Math.max(A,zingchart.exec(n.K,"getbubblesize",{graphid:s.graphid,plotindex:s.plotindex,value:x[1]})),v=Math.min(v,zingchart.exec(n.K,"getbubblesize",{graphid:s.graphid,plotindex:s.plotindex,value:0===x[0]?x[0]+x[2]:x[0]})),p=x[0];p<=x[1];p+=x[2])p>0&&(m={decimals:z,short:!0,"thousands-separator":",","decimals-separator":"."},ZC._cp_(c.item,m),_=zingchart.formatNumber(x[1],m),Z.append({"font-size":10,text:_}),Z.append(c.item),Z.parse(),C=Math.max(C,Z.I));var M=ZC._i_(c.padding||5),E=zingchart.getInstance(o,"box");E.append({id:o.K+"-bubblelegend-box"}),"v"===h?E.append({width:2*M+2*A+10+C,height:2*M+2*A*y+10*(y-1)+5}):E.append({width:2*M+2*A*y+10*(y-1)+y*C,height:2*M+2*A+30}),E.append(o.o["bubble-legend"]),E.parse();var w={type:"rect",x:E.iX+E.I/2,y:E.iY+E.F/2,width:E.I,height:E.F,"background-color":"#fff"};ZC._cp_(o.o["bubble-legend"],w),f.push(w);var I=0;for(u in r){s=r[u],z=(x=ZC.AQ.WI(s.min,s.max))[3];var K=[];for(p=x[0];p<=x[1];p+=x[2])p>0&&K.push(p);var L=[];for(A<15?L.push(K[K.length-1]):A>=15&&A<25?L.push(K[0],K[K.length-1]):A-v>=10?L.push(K[0],K[Math.floor(K.length/2.5)],K[K.length-1]):L.push(K[0],K[K.length-1]),p=0;p<L.length;p++){var V=zingchart.exec(n.K,"getbubblesize",{graphid:s.graphid,plotindex:s.plotindex,value:L[p]});m={decimals:z,short:!0,"thousands-separator":",","decimals-separator":"."},ZC._cp_(c.item,m),_=zingchart.formatNumber(L[p],m);var X,N,Y=n.K+"_"+s.graphid;y>1&&(Y+="_"+s.plotindex),"h"===h?(X=E.iX+I*(10+2*A+C)+M,N=E.iY+A+M+15):(X=E.iX+A+M,N=E.iY+M+2*A+I*(10+2*A)+5),zingchart.plugins.bubblelegend.info[Y]={x:X,y:N,layout:h};var F={id:o.K+"-bubblelegend-circle_"+I+"_"+p,type:"circle",size:V,alpha:.25,"background-color":y>1?s.color:"#999","line-style":"dotted","border-width":1,"border-alpha":1,"border-color":"#333"};if("h"===h){var j=N+(p%2==0?-1:1)*(A+10);p===L.length-1&&3===L.length&&(j=N-A/2-5),ZC._cp_({x:X+V,y:N,connector:{"line-width":1,"line-style":"dotted","line-color":"#333",anchor:"l",points:[[X+2*V,N],[X+2*V,j]]}},F)}else ZC._cp_({x:X,y:N-V,connector:{"line-width":1,"line-style":"dotted","line-color":"#333",anchor:"l",points:[[X,N-2*V],[X+A+10,N-2*V]]}},F);ZC._cp_({label:{color:"#666","font-size":10,align:"left",text:_}},F),ZC._cp_(c.marker,F),ZC._cp_(c.connector,F.connector),ZC._cp_(c.item,F.label),f.push(F)}I++}zingchart.exec(n.K,"addobject",{type:"shape",data:f})}}}),zingchart.bind(null,"node_mouseout",function(e){var n=zingchart.getLoader(e.id),i=zingchart.getModules(n);-1!==ZC.AV(i,"bubble-legend")&&zingchart.exec(e.id,"removeobject",{type:"shape",dynamic:!0,id:e.id+"_"+e.graphindex+"-bubblelegend-circle"})}),zingchart.bind(null,"node_mouseover",function(e){var n=zingchart.getLoader(e.id),i=zingchart.getModules(n);if(-1!==ZC.AV(i,"bubble-legend")&&null!==ZC._n_(e.size)){var a=e.id+"_"+e.graphindex;zingchart.plugins.bubblelegend.info[a]||(a+="_"+e.plotindex);var t={id:e.id+"_"+e.graphindex+"-bubblelegend-circle",type:"circle",size:e.size,"border-width":1,"border-color":"#333"};"h"===zingchart.plugins.bubblelegend.info[a].layout?(t.x=zingchart.plugins.bubblelegend.info[a].x+e.size,t.y=zingchart.plugins.bubblelegend.info[a].y):(t.x=zingchart.plugins.bubblelegend.info[a].x,t.y=zingchart.plugins.bubblelegend.info[a].y-e.size),zingchart.exec(e.id,"addobject",{type:"shape",dynamic:!0,data:t})}});