-
Notifications
You must be signed in to change notification settings - Fork 45
/
zingchart-flame.min.js
8 lines (7 loc) · 7.34 KB
/
zingchart-flame.min.js
1
2
3
4
5
6
7
8
/*
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 [email protected].
Build 2.9.15_ES6
*/
zingchart.setModule("flame"),function(){zingchart.plugins.flame=zingchart.plugins.flame||{};var t={},e={},a={},l={},o={};zingchart.bind(null,"dataparse",function(i,r){var n,p,_,C,Z,d,c,v,h;for(C=0,Z=r[ZC._[16]].length;C<Z;C++)if(r[ZC._[16]][C].type&&("flame"===r[ZC._[16]][C].type||"vflame"===r[ZC._[16]][C].type)){a[i.id]||(a[i.id]={}),l[i.id]||(l[i.id]=-1),o[i.id]=[],t[i.id]||(t[i.id]=JSON.stringify(r));var f=r[ZC._[16]][C].type;r[ZC._[16]][C]["plugin-type"]=f;var s=r[ZC._[16]][C];zingchart.normalize(s),s.type="flame"===f?"hbar":"vbar";var g={};s.options&&(g=s.options[f]||s.options),ZC._todash_(g);var u=g.root||"";e[i.id]=u;var x=g.palette||["#6A921F","#007FA3","#A62B02","#B79007","#563D02","#0B32A0","#00BAF2","#E80C60","#E2D51A","#9B26AF","#FB301E","#00AE4D","#20398B"],m=g["text-attr"]||"text",b=g["value-attr"]||ZC._[9];if(s[ZC._[11]]=s[ZC._[11]]||[],!(s[ZC._[11]]instanceof Array)){var z=[],A={},y=function(t,e){var a=(t.text||t.name||t[m]).toLowerCase().replace(/[^a-z0-9_]+/gi,"");A[a]?a+=A[a]++:A[a]=1;var l={id:a,text:t.text||t.name||t[m]||a,value:t[ZC._[9]]||t[ZC._[21]]||t[b],parent:e||""};if(z.push(l),t.children)for(var o=0;o<t.children.length;o++)y(t.children[o],a)};y(s[ZC._[11]]),s[ZC._[11]]=z}for(var F={},k=[].concat(s[ZC._[11]]).reverse(),Y=0,w=k.length,B=0;k.length&&w-- >=0;)for(n=k.length-1;n>=0;n--)d=(c=k[n]).id||"id"+Y++,""===(h=c.parent||"")?(F[d]={id:d,level:0,parent:"",text:c.text||c.name||c[m]||d,value:c[ZC._[9]]||c[ZC._[21]]||c[b],children:[]},o[i.id].push(d),k.splice(n,1)):F[h]&&(F[h].children.push(d),F[d]={id:d,level:F[h].level+1,parent:h,text:c.text||c.name||c[m]||d,value:c[ZC._[9]]||c[ZC._[21]]||c[b],children:[]},k.splice(n,1),B=Math.max(B,F[d].level));var X=function(t,e){return e=e||[],F[t]&&""!==F[t].parent&&(e.push(F[t].parent),e=e.concat(X(F[t].parent))),e};if(""!==u){for(d in F)d!==u?(v=X(d),-1===ZC.AV(v,u)&&delete F[d]):(F[d]["up-parent"]=F[d].parent,F[d].parent="");var M=F[u].level;for(d in F)F[d].level-=M;B-=M}var V=0,E=0;for(_=0;_<=B;_++){if(0===_)for(d in F)0===F[d].level&&E++;for(d in F){var I="";a[i.id][d]?I=a[i.id][d]:(F[d].level===_&&(I=0===F[d].level||1===F[d].level&&1===E?x[V++%x.length]:F[F[d].parent].color),a[i.id][d]=I),F[d].color=I}}var J=function(t){if(F[t]){if(null===ZC._n_(F[t][ZC._[9]]))if(0===F[t].children.length)F[t][ZC._[9]]=0;else{for(var e=0,a=0;a<F[t].children.length;a++)e+=J(F[t].children[a]);F[t][ZC._[9]]=e}return parseFloat(F[t][ZC._[9]])}};for(d in F)F[d][ZC._[9]]=J(d);if(-1===l[i.id]){for(d in F)if(0!==F[d].level&&(1!==F[d].level||1!==E)&&a[i.id][d]){v=X(d);var K=1===E?v[v.length-2]:v[v.length-1],D=1-F[d][ZC._[9]]/F[K][ZC._[9]];a[i.id][d]=F[d].color=ZC.AP.Q3(F[d].color,40*D)}l[i.id]=1}var L=[],N=0;for(_=0;_<=B;_++){if(L[_]){var P=[];for(n=0;n<L[_].length;n++){var G=(c=F[L[_][n]]).children,R=0;for(p=0;p<G.length;p++)P.push(G[p]),R+=F[G[p]][ZC._[9]];if(R<c[ZC._[9]]){var j="sbfakeid"+N++;F[j]={id:j,parent:c.id,value:c[ZC._[9]]-R,level:c.level,children:[],fake:!0,color:c.color},P.push(j)}}L[_]=[].concat(P)}else for(d in L[_]=[],F)F[d].level===_&&L[_].push(d);_<B&&(L[_+1]=[].concat(L[_]))}var O=0;for(n=0;n<L[0].length;n++)O+=F[L[0][n]].value;for(s.flat=!0,s.plotarea=s.plotarea||{},s.plotarea["mask-tolerance"]=s.plotarea["mask-tolerance"]||[0,0],s[ZC._[50]]=s[ZC._[50]]||{},s[ZC._[50]].visible=!1,s[ZC._[51]]=s[ZC._[51]]||{},s[ZC._[51]].visible=!1,s[ZC._[51]].zooming=!0,s[ZC._[51]]["min-value"]=0,s[ZC._[51]]["max-value"]=O,s[ZC._[51]].step=O/100,s[ZC._[51]].normalize=!1,s.zoom=s.zoom||{},s.tooltip=s.tooltip||{},s.tooltip.align=ZC._c_(s.tooltip.align,"left"),s.plot=s.plot||{},s.plot.aspect="histogram",s.plot["bar-width"]="100%",s.plot["bars-overlap"]="100%",s.plot.tolerance=-5,s.plot["fast-rules"]=!0,s.plot.alpha=ZC._c_(s.plot.alpha,1),s.plot[ZC._[62]]=ZC._c_(s.plot[ZC._[62]],1),s.plot[ZC._[61]]=ZC._c_(s.plot[ZC._[61]],"#cccccc"),s.plot["border-alpha"]=ZC._c_(s.plot["border-alpha"],.2),s.plot[ZC._[17]]=s.plot[ZC._[17]]||{},s.plot[ZC._[17]]["js-rule"]="zingchart.plugins.flame.valueBoxJsRule()",s.plot[ZC._[17]]["tooltip-text"]=ZC._c_(s.plot[ZC._[17]]["tooltip-text"],'<span style="font-size:13px">%plot-text</span><br/>Value:%node-value (%data-pc-value%)'),s.plot[ZC._[17]].text=ZC._c_(s.plot[ZC._[17]].text,"%data-vbtext"),s.plot[ZC._[17]][ZC._[7]]=ZC._c_(s.plot[ZC._[17]][ZC._[7]],"bottom-in"),s.plot[ZC._[17]].align=ZC._c_(s.plot[ZC._[17]].align,"left"),s.plot[ZC._[17]].color=ZC._c_(s.plot[ZC._[17]].color,"#000000"),s.plot[ZC._[17]]["font-size"]=ZC._c_(s.plot[ZC._[17]]["font-size"],11),s.plot[ZC._[17]]["font-weight"]=ZC._c_(s.plot[ZC._[17]]["font-weight"],"normal"),s.plot[ZC._[17]].tolerance=[0,0,0,0],s.plot[ZC._[17]].angle=ZC._c_(s.plot[ZC._[17]].angle,"flame"===f?0:90),delete s.options,delete s[ZC._[11]],s[ZC._[11]]=[],_=0;_<=B;_++){var Q=0,S=-1;for(n=0;n<L[_].length;n++){var q=F[L[_][n]].text,H=q,T=F[L[_][n]].id;h=F[L[_][n]]["up-parent"]||F[L[_][n]].parent,0===_&&(""!==h||1===E&&o[i.id].length>1&&-1!==ZC.AV(o[i.id],T))&&(H="\u25b2 "+H),c={"data-l0items":E,"data-parent":h,"data-uid":T,"data-level":F[L[_][n]].level,"data-plottype":f,"data-vbtext":H,"data-vbfontsize":s.plot[ZC._[17]]["font-size"],"data-value":F[L[_][n]][ZC._[9]],"data-percent":(F[L[_][n]][ZC._[9]]/O*100).toFixed(2),"data-local-value":F[L[_][n]][ZC._[9]],"data-local-percent":(F[L[_][n]][ZC._[9]]/O*100).toFixed(2),"data-offset":Q,"-tooltip-text":'<span style="font-size:19px">%data-vbtext</span><br>Value:%data-value (%data-percent%)',"tooltip-text":'<span style="font-size:19px">%data-vbtext</span><br>Value:%data-local-value (%data-local-percent%)',text:q,"offset-values":[Q],values:[[F[L[_][n]].level,F[L[_][n]][ZC._[9]]]],"background-color":F[L[_][n]].color,"hover-state":{"background-color":ZC.AP.JX(F[L[_][n]].color,20)}},Q+=F[L[_][n]][ZC._[9]],F[L[_][n]].fake&&(c.visible=!1),F[L[_][n]].fake?-1===S?(s[ZC._[11]].push(c),S=s[ZC._[11]].length-1):s[ZC._[11]][S][ZC._[5]][0][1]+=c[ZC._[5]][0][1]:(S=-1,s[ZC._[11]].push(c))}}}return r}),zingchart.plugins.flame.onNodeClick=function(t){var e=zingchart.getLoader(t.id);if(e&&0===t.ev.button){var a=zingchart.getGraph(e,t.graphid);if(a&&("flame"===a.o["plugin-type"]||"vflame"===a.o["plugin-type"])){for(var l=0;l<a.AY.A4.length;l++)a.AY.A4[l].KC["local-value"]=Math.min(t[ZC._[9]],a.AY.A4[l].KC[ZC._[9]]),a.AY.A4[l].KC["local-percent"]=Math.min(100,100*a.AY.A4[l].KC[ZC._[9]]/t[ZC._[9]]).toFixed(2);zingchart.exec(t.id,"zoomto",{graphid:t.graphid,ymin:t["data-offset"],ymax:t["data-offset"]+t[ZC._[9]]})}}},zingchart.bind(null,"node_click",zingchart.plugins.flame.onNodeClick),zingchart.plugins.flame.valueBoxJsRule=function(t){var e=zingchart.getLoader(t.id),a=zingchart.getGraph(e,t.graphid).P,l={visible:!1},o=t.width,i=t.height;o=t.x<=a.iX?t.x+t.width>=a.iX+a.I?a.I:t.width-(a.iX-t.x):t.x+t.width<=a.iX+a.I?t.width:a.iX-a.I-t.x,i=t.y<=a.iY?t.y+t.height>=a.iY+a.F?a.F:t.height-(a.iY-t.y):t.y+t.height<=a.iY+a.F?t.height:a.iY-a.F-t.y;var r="flame"===t["data-plottype"]?o:i;if(r>=40){l.visible=!0,t["data-vbtext"]=t["data-vbtext"]||"";var n=Math.round(r/(.7*t["data-vbfontsize"]));n>=t["data-vbtext"].length?l.text=t["data-vbtext"]:l.text=t["data-vbtext"].substring(0,n-3)+"..."}return l}}();