All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.views.sonar-treemap-view-min.js Maven / Gradle / Ivy

AJS.$.namespace("AJS.sonar.views.treemap");AJS.sonar.views.treemap.VIEW_NAME="treemap";AJS.sonar.views.treemap.DEFAULT_TREEMAP_DIMENSIONS={width:300,height:300};AJS.sonar.views.treemap.DEFAULT_COLOR_METRIC="violations_density";AJS.sonar.views.treemap.DEFAULT_SIZE_METRIC="ncloc";AJS.sonar.views.treemap.METRICS=AJS.sonar.views.treemap.DEFAULT_SIZE_METRIC+","+AJS.sonar.views.treemap.DEFAULT_COLOR_METRIC;AJS.sonar.views.treemap.generateView=function(D,E,F,A){var C=AJS.$("body");var B={width:(C.width()-20),height:(C.width()-20)};return AJS.sonar.views.treemap.generateViewDetailed(D,E,F.key,A,AJS.sonar.views.treemap.DEFAULT_SIZE_METRIC,AJS.sonar.views.treemap.DEFAULT_COLOR_METRIC,B,null)};AJS.sonar.views.treemap.generateViewDetailed=function(I,C,L,E,D,N,A,B){AJS.sonar.text.load(I);var J=AJS.sonar.views.createViewContainer();var M=AJS.sonar.utils.getMetricFromMetricsArray(E,D);var K=AJS.sonar.utils.getMetricFromMetricsArray(E,N);if(A==null||A.width==undefined||A.height==undefined){A={width:0,hieght:0}}if(A.width<1||A.height<1){A=AJS.sonar.views.treemap.DEFAULT_TREEMAP_DIMENSIONS}var F=AJS.$("
").addClass("treemap-header");J.append(F);var G=AJS.$("
").attr({id:"sonarTreemap"});J.append(G);var H=function(){AJS.$("#treemap-loading").show();var Q=AJS.sonar.utils.getMetricFromMetricsArray(E,AJS.$("#sizeSelect").val());var P=AJS.sonar.utils.getMetricFromMetricsArray(E,AJS.$("#colorSelect").val());AJS.sonar.views.treemap.populateTreemap(G,C,L,E,Q,P,A);if(B!=null){try{B(Q,P)}catch(O){}}};AJS.$("
").addClass("center-div").text(AJS.sonar.text.getMsg("sonar.views.treemap.no.data")).appendTo(G)}else{var K="PRJ";if(H!=""){var M=0;AJS.$(L).each(function(N,O){if(O.scope=="PRJ"){M++}});if(M==1){K="DIR"}}G.treemap(A.width,A.height,{getData:function(){var N=false;var O=[];AJS.$(L).each(function(Q,S){if(!(H!=""&&H==S.key)&&S.scope==K){var T=AJS.sonar.utils.getMeasureFromResource(S,J.key);var P=AJS.sonar.utils.getMeasureFromResource(S,I.key);if(!isNaN(parseFloat(T.val))&&parseFloat(T.val)>0){C.push({id:S.id,name:S.name,size:{metric:J,measure:T},color:{metric:I,measure:P}});var R=[AJS.$("
").addClass("sonar-treemap-cell").text(S.name),parseFloat(T.val),AJS.sonar.views.treemap.getTreemapResourceColor(P,I),S.id];O.push(R)}}});if(O.length==0){O=[];O.push([AJS.$("
").addClass("sonar-treemap-cell").text(AJS.sonar.text.getMsg("sonar.views.treemap.no.data")),100,AJS.sonar.views.treemap.getTreemapResourceColor(null,I)])}return O},borderWidth:2,borderColor:"#FFF",getColor:function(O,N){return O}});AJS.$(C).each(function(O,P){var N=AJS.$("#"+P.id);N.click(function(Q){parent.location.href=E.host+"/project/index/"+P.id});N.tooltip({delay:0,showUrl:false,track:true,bodyHandler:function(){var Q=AJS.$("
").addClass("treemap-tooltip");AJS.$("
").addClass("treemap-tooltip-header").append(P.name).appendTo(Q);AJS.$("
").addClass("tremap-tooltip-measure").append(AJS.$("").text(P.size.metric.name)).append(": ").append(AJS.$("").text(P.size.measure.frmt_val)).appendTo(Q);AJS.$("
").addClass("tremap-tooltip-measure").append(AJS.$("").text(P.color.metric.name)).append(": ").append(AJS.$("").text(P.color.measure.frmt_val)).appendTo(Q);return Q}})})}AJS.$("#treemap-loading").hide()},function(K,L){G.empty();AJS.$("
").addClass("center-div").text(AJS.sonar.text.getMsg("sonar.views.treemap.failed.to.get.data")).appendTo(G)});AJS.$.ajax(D)};AJS.sonar.views.treemap.getTreemapResourceColor=function(C,J){var K=0,D=100;var H={r:255,g:0,b:0};var F={r:255,g:176,b:0};var G={r:0,g:255,b:0};if(C!=null&&C.alert!=null){if(C.alert==="OK"){return"#00FF00"}else{if(C.alert==="WARN"){return"#FF8500"}else{if(C.alert==="ERROR"){return"#F93F40"}}}}var I;if(C==null){I=-1}else{if(J.val_type==="LEVEL"){if(C.val==="OK"){I=100}else{if(C.val==="WARN"){I=50}else{if(C.val==="ERROR"){I=0}}}}else{I=C.val}}if(I<0){return"#DDDDDD"}else{var A=(D-K)/2;var L=(K+D)/2;var E;if(I>L){var B=((I-L)/A)*100;if(J.direction>=0){E=AJS.sonar.utils.mixColors(G,F,B)}else{E=AJS.sonar.utils.mixColors(H,F,B)}}else{var B=((L-I)/A)*100;if(J.direction>=0){E=AJS.sonar.utils.mixColors(H,F,B)}else{E=AJS.sonar.utils.mixColors(G,F,B)}}return"#"+AJS.sonar.utils.rgbToHex(E.r,E.g,E.b)}};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy