Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
scripts.jQuery.treemap-min.js Maven / Gradle / Ivy
(function(A){A.fn.treemap=function(C,F,E){E=A.extend({labelCell:0,dataCell:1,colorCell:2,headHeight:20,borderWidth:1,borderColor:"#000",getColor:B.getColor,sort:true,nested:false,legend:false},E);var D=E.target;return this.pushStack(A.map(this,function(H){var I;if(!E.getData){if(!A.nodeName(H,"table")){return }I=B.getDataFromTable(H,E)}else{I=E.getData(H)}I=I.concat();if(A.fn.treemap.caller!=B.layoutRow){E.minColorValue=Number.POSITIVE_INFINITY;E.maxColorValue=Number.NEGATIVE_INFINITY;if(!E.colorDiscreteVal){E.colorDiscreteVal={num:0}}B.normalizeValues(I,E);E.colorDiscrete=E.minColorValue==Number.POSITIVE_INFINITY;E.rangeColorValue=E.maxColorValue-E.minColorValue}if(E.sort){I.sort(function(K,J){var M=J[1],L=K[1];M=M.constructor==Array?B.getValue(M):M;L=L.constructor==Array?B.getValue(L):L;return M-L})}E.target=D||H;E.numSquare=0;B.render(I,F,C,E);if(A.fn.treemap.caller!=B.layoutRow&&E.legend){jQuery(E.target).append(B.legend(F,E))}if(E.target==H&&A.nodeName(H,"table")){var G=jQuery(H).find(">").insertBefore(H);A(H).remove();H=G.get()}return H}))};A.fn.treemapClone=function(){return this.pushStack(jQuery.map(this,function(C){return C.outerHTML?jQuery(C.outerHTML)[0]:C.cloneNode(true)}))};A.fn.treemapAppend=function(F){var E=this[0];for(var D=0,C=F.length;DE.maxColorValue){E.maxColorValue=C}if(!E.colorDiscreteVal[C]){E.colorDiscreteVal[C]=E.colorDiscreteVal.num++}}}},getDataFromTable:function(D,C){var E=[];if(C.labelCell==undefined){C.labelCell=C.dataCell}A("tbody tr",D).each(function(){var F=A(">",this);var G=[F.eq(C.labelCell).html(),F.eq(C.dataCell).html(),F.eq(C.colorCell).html()];E.push(G)});return E},emptyView:A("").addClass("treemapView"),render:function(G,F,C,D){D.height=F;D.width=C;var E=B.calculateArea(G);D.viewAreaCoeff=C*F/E;D.view=B.emptyView.clone().css({width:C,height:F});D.content=[];B.squarify(G,[],F,true,D);D.view.treemapAppend(D.content);A(D.target).empty().treemapAppend(D.view)},squarify:function(E,K,J,D,M){if(J<=0){return }var H=K,L,I,F;do{K=H;L=B.calculateArea(K);if(E.length==0){return B.layoutRow(K,J,D,L,M,true)}F=E.shift();H=K.concat();H.push(F);I=L+(F[1].constructor==Array?B.getValue(F[1]):F[1])}while(B.worst(K,J,L,M.viewAreaCoeff)>=B.worst(H,J,I,M.viewAreaCoeff));var G=B.layoutRow(K,J,D,L,M);E.unshift(F);if(!G){G=B.layoutRow([["",L]],J,D,L,M,true)}var C;if(D){M.width-=G;C=M.width}else{M.height-=G;C=M.height}B.squarify(E,[],C,!D,M)},worst:function(J,I,K,F){var G=J.length;if(!G){return Number.POSITIVE_INFINITY}var E=I*I,H=K*K*F;var D=(E*(J[0][1].constructor==Array?B.getValue(J[0][1]):J[0][1]))/H;var C=H/(E*(J[G-1][1].constructor==Array?B.getValue(J[G-1][1]):J[G-1][1]));return Math.max(D,C)},emptyCell:A("
").addClass("treemapCell").css({"float":"left",overflow:"hidden"}),emptySquare:A("
").addClass("treemapSquare").css("float","left"),layoutRow:function(M,Q,F,T,H,P){var V=B.emptySquare.treemapClone();var K,c=T/Q;if(F){K=P?H.width:Math.min(Math.round(c*H.viewAreaCoeff),H.width);V.css({width:K,height:Q}).addClass("treemapV")}else{K=P?H.height:Math.min(Math.round(c*H.viewAreaCoeff),H.height);V.css({height:K,width:Q}).addClass("treemapH")}var R=M.length-1,D=0,d=H.borderWidth,L=H.borderColor,Y=d*2,I=[];for(var b=0;b<=R;b++){var Z=M[b],S=Z[1].constructor==Array,J=[],f=S?B.getValue(Z[1]):Z[1];var C=B.emptyCell.treemapClone();if(!S){C.append(Z[0])}var a=b==R;var G=K,N=a?Q-D:Math.round(f/c);if(N<=0){break}D+=N;var e={};if(d&&K>Y&&N>Y){if(jQuery.boxModel){G-=d*(2-(H.numSquare>=2||!H.numSquare&&H.nested?1:0)-(P&&H.nested?1:0));N-=d*(2-(!a||H.nested?1:0)-(H.numSquare>=1&&!b?1:0))}e.border=d+"px solid "+L;if(!a||H.nested){e["border"+(F?"Bottom":"Right")]="none"}if(H.numSquare>=2||!H.numSquare&&H.nested){e["border"+(F?"Left":"Top")]="none"}if(H.numSquare>=1&&!b){e["border"+(F?"Top":"Left")]="none"}if(P&&H.nested){e["border"+(F?"Right":"Bottom")]="none"}}var U=F?N:G,X=F?G:N;e.height=U+"px";e.width=X+"px";if(S){if(H.headHeight){J=A("
").css({width:X,height:H.headHeight,overflow:"hidden"}).html(Z[0]);if(F){U=N-=H.headHeight}else{U=G-=H.headHeight}}if(U>0){var O={};for(var E in H){O[E]=H[E]}O.target=null;O=jQuery.extend(O,{getData:function(){return Z[1].concat()},nested:true});C.treemap(X,U,O)}C.prepend(J)}else{if(Z[2]){e.backgroundColor=H.getColor(Z[2],H)}}if(Z[3]){C.attr({id:Z[3]})}var W=C[0].style;for(var E in e){W[E]=e[E]}I.push(C[0])}H.content.push(V.treemapAppend(I)[0]);H.numSquare++;return K},calculateArea:function(G){if(G.total){return G.total}var D=0,F=G.length;for(var C=0;C
").css({position:"absolute",left:25,width:200}),legend:function(G,E){var C=A("").css({position:"relative","float":"left",height:G-2});var H=A("
").css({width:20,height:G-2,border:"1px solid"});E.view.css({"float":"left",marginRight:20});if(E.colorDiscrete){A.each(E.colorDiscreteVal,function(L,O){if(L!="num"){L=E.descriptionCallback?E.descriptionCallback(L):L;var K=Math.round(O*G/E.colorDiscreteVal.num);var M=A("
").css({height:20,width:20,backgroundColor:B.getColor(L,E),position:"absolute",bottom:K});var N=B.emptyLegendDescr.clone().text(L).css("bottom",K);C.append(M).append(N)}})}else{for(var F=G-1;F>1;F--){var D=A("
").height(1).css("backgroundColor",B.getColorCode(F/G));H.append(D)}C.append(H);for(var F=0;F<10;F++){var J=F*E.rangeColorValue/10+E.minColorValue;J=E.descriptionCallback?E.descriptionCallback(J):J;var I=B.emptyLegendDescr.clone().text(J.toString()).css("bottom",Math.round(F*G/10));C.append(I)}}return C}}})(jQuery);