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