]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3762 Provide a new Histogram widget to display a measure filter
authorStas Vilchik <vilchiks@gmail.com>
Fri, 20 Dec 2013 07:01:06 +0000 (13:01 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 20 Dec 2013 07:56:43 +0000 (13:56 +0600)
Latest updates

plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb
sonar-server/src/main/webapp/javascripts/widgets/histogram.js

index 9d85ce988604552d44fa4ae1a218a0136329ad01..27816a9722e1f6b5ea4fef51951b8c42c5428ebc 100644 (file)
@@ -15,9 +15,7 @@
 
   <!--[if (gte IE 9)|!(IE)]><!-->
   <% if chartTitle %>
-  <h3 style="text-align: center;"><%= h(chartTitle) -%></h3>
-  <% else %>
-  <h3 style="text-align: center;"><%= h widget_properties["metric"].short_name -%></h3>
+  <h3><%= h(chartTitle) -%></h3>
   <% end %>
   <!--<![endif]-->
 </div>
index ebe5440f0ffa033aeef86e9bde25d972b9c2ba7d..fc998e39d58e17be865c57977e077df7d12223d4 100644 (file)
@@ -125,6 +125,13 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
     };
 
 
+    // Configure metric label
+    this.metricLabel = this.gWrap.append('text')
+        .text(this.metrics()[this.mainMetric].name)
+        .attr('dy', '9px')
+        .style('font-size', '11px');
+
+
     // Show maxResultsReached message
     if (this.maxResultsReached()) {
       this.maxResultsReachedLabel = this.gWrap.append('text')
@@ -154,7 +161,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
 
     // Update available size
     this.availableWidth = this.width() - this.margin().left - this.margin().right - this.legendWidth();
-    this.availableHeight = barHeight * this.components().length;
+    this.availableHeight = barHeight * this.components().length + this._lineHeight;
     var totalHeight = this.availableHeight + this.margin().top + this.margin().bottom;
     if (this.maxResultsReached()) {
       totalHeight += this._lineHeight;
@@ -168,10 +175,15 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         .attr('height', this.height());
 
 
+    // Update plot
+    this.plotWrap
+        .attr('transform', trans(0, this._lineHeight));
+
+
     // Update scales
-    var xDomain;
-    if (this.options().displayWorstBestValues) {
-      var metric = this.metrics()[this.mainMetric];
+    var xDomain,
+        metric = this.metrics()[this.mainMetric];
+    if (this.options().displayWorstBestValues && metric.worstValue != null && metric.bestValue != null) {
       xDomain = [metric.worstValue, metric.bestValue];
     } else {
       xDomain = d3.extent(this.components(), function(d) {
@@ -180,7 +192,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
     }
     this.x
         .domain(xDomain)
-        .range([this.availableWidth / 8, this.availableWidth]);
+        .range([0, this.availableWidth]);
 
     this.y
         .domain(this.components().map(function(d, i) { return i; }))
@@ -219,7 +231,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         .transition()
         .attr('x', this.legendWidth())
         .attr('y', 0)
-        .attr('width', function(d) { return widget.x(widget.getMainMetric(d)); })
+        .attr('width', function(d) { return Math.max(2, widget.x(widget.getMainMetric(d))); })
         .attr('height', barHeight);
 
     this.bars.selectAll('.component')
@@ -247,6 +259,11 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         });
 
 
+    // Configure metric label
+    this.metricLabel
+        .attr('transform', trans(this.legendWidth(), 0));
+
+
     // Show maxResultsReached message
     if (this.maxResultsReached()) {
       this.maxResultsReachedLabel