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.34 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
*/
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.B8,e),t.NR[r]&&ZC._cp_(t.NR[r],e),e},t.B8={},t.NR={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,R=n.series||[],A=r.aColLabels.length;for(_=0;_<R.length;_++)g=R[_].values||[],A=Math.max(A,g.length);!H&&r.bHeaderCol&&A++;var M,S=zingchart.getInstance(o,"textbox"),E=Math.floor(x.plotarea.width/A),G=x.plotarea.x,W=x.plotarea.y,I=0;if(r.bHeaderRow){for(M=[],_=0;_<A;_++){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)),_===A-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:W,width:D,text:f,"class":p.join(" "),generated:!0},M.push(m),S.setData({}),S.append(m),u=0,b=p.length;u<b;u++)S.append(e.style["."+p[u]]);S.parse(),I=Math.max(I,S.get("height")),G+=D}for(_=M.length-1;_>=0;_--)M[_].height=I,n.labels.push(M[_])}var N=null;r.bForceHeight&&(N=(x.plotarea.height-I)/R.length),W+=I;for(var j=0,B=R.length;j<B;j++){for(zingchart.normalize(R[j]),G=x.plotarea.x,I=0,M=[],_=0;_<A;_++){if(g=R[j].values||[],f=0===_?r.bHeaderCol?r.aRowLabels[j]: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===j&&p.push("tr_first","tr_first_"+v),j===B-1&&p.push("tr_last","tr_last_"+v),j%2==0?p.push("tr_even","tr_even_"+v):p.push("tr_odd","tr_odd_"+v),p.push("tr_"+j,"tr_"+j+"_"+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)),_===A-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_"+j+"_"+_,"td_"+j+"_"+_+"_"+v),R[j]["data-class"]&&(l=R[j]["data-class"][_])&&(p=p.concat(l.split(" "))),m={id:"td_"+j+"_"+_,x:G,y:W,width:D,text:f,"class":p.join(" "),generated:!0},r.A7){var O={};zingchart.copy(r.A7,O),zingchart.copy(R[j].tooltip,O),null!==ZC._n_(O.visible)&&ZC._b_(O.visible)&&R[j]["data-tooltip-text"]&&R[j]["data-tooltip-text"][_]&&(O.text=R[j]["data-tooltip-text"][_],m.tooltip=O)}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(),I=Math.max(I,S.get("height")),M.push(m),G+=D}for(_=M.length-1;_>=0;_--)null!==ZC._n_(N)&&N>1?M[_].height=N:M[_].height=I,n.labels.push(M[_]);W+=null!==ZC._n_(N)&&N>1?N:I}}return e})}();