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