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) 7.35 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("grid"),function(){var t,r;ZC.ZCGrid=((t=function(){this.aColLabels=[],this.aColWidths=[],this.aColInfo=[],this.aRowLabels=[],this.bHeaderRow=!0,this.bHeaderCol=!1,this.bForceHeight=!1,this.oDataSource=null,this.A7=null,this._p_=function(t){var r=(t=String(t).replace(/[^0-9\.\%]/gi,"")).indexOf("%");return-1!==r&&(t=t.substring(0,r),t=parseFloat(t)/100),parseFloat(t)},this._b_=function(t){return"false"!==t&&"0"!==t&&("true"===t||"1"===t||t&&!0)}}).getDefaults=function(r){var e={};return ZC._cp_(t.B6,e),t.NT[r]&&ZC._cp_(t.NT[r],e),e},t.B6={},t.NT={light:{".th":{"background-color":"#808285","font-weight":"bold",color:"#fff","border-right":"1px solid #9FA0A2","text-align":"left",padding:"10 8"},".th_last":{"border-right":"none"},".tr_even":{"background-color":"#fff"},".tr_odd":{"background-color":"#F5F7F7"},".td":{"border-width":1,"border-color":"#E6E7E8","text-align":"left",color:"#808285",padding:"10 8"}},dark:{".th":{"background-color":"#808285","font-weight":"bold",color:"#fff","border-right":"1px solid #9FA0A2","text-align":"left",padding:"10 8"},".th_last":{"border-right":"none"},".tr_even":{"background-color":"#fff"},".tr_odd":{"background-color":"#F5F7F7"},".td":{"border-width":1,"border-color":"#E6E7E8","text-align":"left",color:"#808285",padding:"10 8"}},classic:{".th":{"background-color":"#6a921f #a7da47",padding:"8 4",bold:1,align:"left","vertical-align":"top","clip-text":!0,color:"#fff",flat:!0,"border-bottom":"2px solid #999","border-right":"1px solid #fff"},".th_last":{"border-right":"0px solid #fff"},".th_first_header":{"background-color":-1,"border-right":"2px solid #999"},".tr":{padding:4,align:"left","vertical-align":"top","clip-text":!0,color:"#000","border-bottom":"1px solid #ccc"},".tr_odd":{"background-color":"#eee"},".tr_even":{"background-color":"#ddd"},".td":{"clip-text":!0,flat:!0,"border-right":"1px solid #ccc"},".td_first_header":{bold:!0,"border-right":"2px solid #999"},".td_last":{"border-right":"0px solid #ccc"},"tooltip[grid]":{visible:!0,"background-color":"#eee","border-color":"#666","border-width":1,padding:"4 8",color:"#000"}},negative:{".th":{"background-color":"#333 #666",padding:"8 4",bold:1,align:"left","vertical-align":"top","clip-text":!0,color:"#fff","border-bottom":"2px solid #999","border-right":"1px solid #fff"},".th_last":{"border-right":"0px solid #fff"},".th_first_header":{"background-color":-1,"border-right":"2px solid #999"},".tr":{padding:4,align:"left","vertical-align":"top",color:"#000","border-bottom":"1px solid #ccc"},".tr_odd":{"background-color":"#eee"},".tr_even":{"background-color":"#ddd"},".td":{"clip-text":!0,"border-right":"1px solid #ccc"},".td_first_header":{bold:!0,"border-right":"2px solid #999"},".td_last":{"border-right":"0px solid #ccc"}}},t),zingchart.bind(null,"dataparse",function(t,e){var l,o=zingchart.getLoader(t.id);zingchart.initThemes(o);for(var a=ZC.ZCGrid.getDefaults(t.theme),d=0,i=e.graphset.length;d<i;d++)if("grid"===e.graphset[d].type){var s=e.graphset[d].type,n=e.graphset[d],h={};n.options&&(h=n.options[s]||n.options),zingchart.normalize(h);var _,c,g,p,u,b,f,C=h.style||{},x=zingchart.getGraphInfo(o,e,d),v=n.id||"graph"+d;if(n.labels||(n.labels=[]),r=new ZC.ZCGrid,null!==ZC._n_(l=h["col-labels"])&&(r.aColLabels=l),null!==ZC._n_(l=h["row-labels"])&&(r.aRowLabels=l),null!==ZC._n_(l=h["col-widths"])&&(r.aColWidths=l),null!==ZC._n_(l=h["data-source"])&&(r.oDataSource=l),null!==ZC._n_(l=h["header-row"])&&(r.bHeaderRow=r._b_(l)),null!==ZC._n_(l=h["header-col"])&&(r.bHeaderCol=r._b_(l)),null!==ZC._n_(l=h["force-height"])&&(r.bForceHeight=r._b_(l)),null!==ZC._n_(l=n.tooltip)&&(r.A7=l,zingchart.copy(a["tooltip[grid]"],r.A7)),null===ZC._n_(e.style)&&(e.style={}),zingchart.copy(a,e.style),zingchart.copy(C,e.style),r.oDataSource){var Z=-1;if(""!==(v=r.oDataSource.graph||""))for(var w=0,y=e.graphset.length;w<y;w++)(null!==ZC._n_(e.graphset[w].id)&&e.graphset[w].id===v||d+""===v)&&(Z=w);if(-1!==Z){null!==ZC._n_(r.oDataSource.scale)&&null!==ZC._n_(l=e.graphset[Z][r.oDataSource.scale])&&null!==ZC._n_(l.values)&&(r.aRowLabels=l.values);var k=e.graphset[Z].series||[],z=[],H=0===r.aColLabels.length;for(H&&r.bHeaderCol&&r.aColLabels.push(" "),_=0,c=k.length;_<c;_++){g=k[_].values||[],f=k[_].text||"",H&&r.aColLabels.push(f);for(var F=0,L=g.length;F<L;F++)null===ZC._n_(z[F])&&(z[F]={values:[]}),z[F].values.push(g[F])}n.series=z}}var m,D,A=n.series||[],M=r.aColLabels.length;for(_=0;_<A.length;_++)g=A[_].values||[],M=Math.max(M,g.length);!H&&r.bHeaderCol&&M++;var R,S=zingchart.getInstance(o,"textbox"),E=Math.floor(x.plotarea.width/M),G=x.plotarea.x,T=x.plotarea.y,W=0;if(r.bHeaderRow){for(R=[],_=0;_<M;_++){for(f=null===ZC._n_(r.aColLabels[_])?" ":r.aColLabels[_]+"",D=E,null!==ZC._n_(l=r.aColWidths[_])&&(D=r._p_(l))<1&&(D=Math.floor(D*x.plotarea.width)),p=["th","th_"+v,"th_"+_,"th_"+_+"_"+v],0===_&&(p.push("th_first","th_first_"+v),r.bHeaderCol&&p.push("th_first_header","th_first_header_"+v)),_===M-1&&p.push("th_last","th_last_"+v),_%2==0?p.push("th_even","th_even_"+v):p.push("th_odd","th_odd_"+v),h["data-class"]&&(l=h["data-class"][_])&&(p=p.concat(l.split(" "))),m={id:"th_"+_,x:G,y:T,width:D,text:f,"class":p.join(" "),generated:!0},R.push(m),S.setData({}),S.append(m),u=0,b=p.length;u<b;u++)S.append(e.style["."+p[u]]);S.parse(),W=Math.max(W,S.get("height")),G+=D}for(_=R.length-1;_>=0;_--)R[_].height=W,n.labels.push(R[_])}var I=null;r.bForceHeight&&(I=(x.plotarea.height-W)/A.length),T+=W;for(var N=0,j=A.length;N<j;N++){for(zingchart.normalize(A[N]),G=x.plotarea.x,W=0,R=[],_=0;_<M;_++){if(g=A[N].values||[],f=0===_?r.bHeaderCol?r.aRowLabels[N]:null===ZC._n_(g[_])?" ":g[_]+"":null===ZC._n_(g[r.bHeaderCol?_-1:_])?" ":g[r.bHeaderCol?_-1:_]+"",D=E,null!==ZC._n_(l=r.aColWidths[_])&&(D=r._p_(l))<1&&(D=Math.floor(D*x.plotarea.width)),p=["tr","tr_"+v],0===N&&p.push("tr_first","tr_first_"+v),N===j-1&&p.push("tr_last","tr_last_"+v),N%2==0?p.push("tr_even","tr_even_"+v):p.push("tr_odd","tr_odd_"+v),p.push("tr_"+N,"tr_"+N+"_"+v),p.push("td","td_"+v),0===_&&(p.push("td_first","td_first_"+v),r.bHeaderCol&&p.push("td_first_header","td_first_header_"+v)),_===M-1&&p.push("td_last","td_last_"+v),_%2==0?p.push("td_even","td_even_"+v):p.push("td_odd","td_odd_"+v),p.push("td_"+_,"td_"+_+"_"+v),p.push("td_"+N+"_"+_,"td_"+N+"_"+_+"_"+v),A[N]["data-class"]&&(l=A[N]["data-class"][_])&&(p=p.concat(l.split(" "))),m={id:"td_"+N+"_"+_,x:G,y:T,width:D,text:f,"class":p.join(" "),generated:!0},r.A7){var B={};zingchart.copy(r.A7,B),zingchart.copy(A[N].tooltip,B),null!==ZC._n_(B.visible)&&ZC._b_(B.visible)&&A[N]["data-tooltip-text"]&&A[N]["data-tooltip-text"][_]&&(B.text=A[N]["data-tooltip-text"][_],m.tooltip=B)}if(S.setData({}),S.append(m),null!==ZC._n_(e.style))for(u=0,b=p.length;u<b;u++)S.append(e.style["."+p[u]]);S.parse(),W=Math.max(W,S.get("height")),R.push(m),G+=D}for(_=R.length-1;_>=0;_--)null!==ZC._n_(I)&&I>1?R[_].height=I:R[_].height=W,n.labels.push(R[_]);T+=null!==ZC._n_(I)&&I>1?I:W}}return e})}();