template.js.plugins.grid.pivot.min.js Maven / Gradle / Ivy
'use strict';(function(l){"function"===typeof define&&define.amd?define(["jquery","./jquery.fmatter","./grid.grouping"],l):"object"===typeof module&&module.exports?module.exports=function(B,p){B||(B=window);void 0===p&&(p="undefined"!==typeof window?require("jquery"):require("jquery")(B));require("./jquery.fmatter");require("./grid.grouping");l(p);return p}:l(jQuery)})(function(l){function B(c,d,l){if(!(this instanceof B))return new B(c);this.aggregator=c;this.finilized=!1;this.context=d;this.pivotOptions=
l}function p(c,d,q,k,m){var h=k.length,p=function(b,a){var c=b,d=a;null==c&&(c="");null==d&&(d="");c=String(c);d=String(d);this.caseSensitive||(c=c.toUpperCase(),d=d.toUpperCase());if(c===d){if(b===a)return 0;if(void 0===b)return-1;if(void 0===a)return 1;if(null===b)return-1;if(null===a)return 1}return ct)a.push(m),g.push([d]);else if(h=this.compareVectors(m,a[t]),0===h)g[t].push(d);else if(1===h||this.skipSort)a.push(m),g.push([d]);else if(h=this.compareVectors(a[0],m),1===h)a.unshift(m),g.unshift([d]);else if(0===h)g[0].push(d);
else for(;;){if(2>t-b){a.splice(t,0,m);g.splice(t,0,[d]);break}e=Math.floor((b+t)/2);h=this.compareVectors(a[e],m);if(0===h){g[e].push(d);break}1===h?t=e:b=e}}};O.extend({pivotSetup:function(c,d){var q=this[0],k=l.isArray,m={},h={groupField:[],groupSummary:[],groupSummaryPos:[]},T={grouping:!0,groupingView:h},g=l.extend({totals:!1,useColSpanStyle:!1,trimByCollect:!0,skipSortByX:!1,skipSortByY:!1,caseSensitive:!1,footerTotals:!1,groupSummary:!0,groupSummaryPos:"header",frozenStaticCols:!1,defaultFormatting:!0,
data:c},d||{}),e,b,a,t=c.length,F,f,x,y,D,U,P=g.xDimension,z=g.yDimension,G=g.aggregates,M,t=g.totalText||g.totals||g.rowTotals||g.totalHeader,u,J=k(P)?P.length:0;y=k(z)?z.length:0;var n=k(G)?G.length:0,A=y-(1===n?1:0),H=[],K=[],Q=[],k=[],Y=["pivotInfos"],V=Array(n),N=Array(y),R,Z,w,W,L,I,C,r,E,S,v;b=function(a,b,d){a=new p(g.trimByCollect,g.caseSensitive,b,a);l.isFunction(d)&&(a.compareVectorsEx=d);a.createDataIndex(c);return a};var ba=function(a,b,c,d,e){var f,h;switch(a){case 1:f=z[d].totalText||
"{0} {1} {2}";h="y"+e+"t"+d;break;case 2:f=g.totalText||"{0}";h="t";break;default:f=1=b;c--)if(K[c]){for(e=0;e<=c;e++)E=H[e].groupHeaders,E[E.length-1].numberOfColumns+=n;F=z[c];f=F.totalHeader;g=F.headerOnTop;for(e=c+1;e<=A-1;e++)H[e].groupHeaders.push({titleText:g&&e===c+1||
!g&&e===A-1?l.isFunction(f)?f.call(q,d,c):O.template.call(q,String(f||""),d[c],c):"",startColumnName:"y"+(a-1)+"t"+c+(1===n?"":"a0"),numberOfColumns:n})}};var X=function(a){a=new B("count"===G[a].aggregator?"sum":G[a].aggregator,q,d);a.groupInfo={iRows:[],rows:[],ys:[],iYs:[]};return a},ca=function(){var a,b;for(a=A-1;0<=a;a--)if(K[a])for(null==N[a]&&(N[a]=Array(n)),b=0;b=f;e--)g=
"y"+a+"t"+e+(1l.inArray(h,k.iYs)&&(k.iYs.push(h),k.ys.push(a)),0>l.inArray(g,k.iRows)&&(k.iRows.push(g),k.rows.push(f)))};if(0===J||0===n)throw"xDimension or aggregates options are not set!";
S=b(P,g.skipSortByX,g.compareVectorsByX);v=b(z,g.skipSortByY,g.compareVectorsByY);d.xIndex=S;d.yIndex=v;for(b=0;bJ&&(T.grouping=!1);h.hideFirstGroupCol=!0;for(b=0;b=b;a--)K[a]&&D(1,a,f-1);r=w;D(0,y-1,f)}for(b=A-1;0<=b;b--)K[b]&&D(1,b,h-1);t&&D(2);r=v.getItem(0);for(a=0;a=b;a--)H[a].groupHeaders.push({titleText:l.isFunction(z[a].label)?z[a].label.call(q,{yData:w[a],yIndex:w,yLevel:a,pivotOptions:g}):w[a],startColumnName:"y"+f+(1===n?"":"a0"),numberOfColumns:n});for(a=0;al.inArray(b,u.iYs)&&(u.iYs.push(f),u.ys.push(w)),0>l.inArray(b,u.iRows)&&(u.iRows.push(b),u.rows.push(e))),da(w,r,I,a,e,b,f);e="y"+f+(1===n?"":"a"+a);M.getResult(C,e);D[e]={colType:0,iY:f,y:w,iA:a,a:I,iRows:L,rows:U}}}r=w}if(null!==r)for(a=0;a
© 2015 - 2025 Weber Informatics LLC | Privacy Policy