]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3762 Provide a new Histogram widget to display a measure filter
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Dec 2013 09:33:41 +0000 (15:33 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 19 Dec 2013 09:33:49 +0000 (15:33 +0600)
Latest updates

plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
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
sonar-server/src/main/webapp/javascripts/widgets/widget.js

index 1f805a745eee6eb345a3c6280e34d3545e685ccf..ad2862407dc603713ab1c980f8e4604844b0a474 100644 (file)
@@ -1135,7 +1135,7 @@ widget.measure_filter_histogram.property.metric.name=Metric
 widget.measure_filter_histogram.property.maxItems.name=Maximum number of components to show
 widget.measure_filter_histogram.property.reverseOrder.name=Reverse sort order of filter
 widget.measure_filter_histogram.property.displayWorstBestValues.name=Display scale with worst and best values when appropriate
-widget.measure_filter_histogram.max_items_reached=Max items are reached.
+widget.measure_filter_histogram.max_items_reached=Only the {0} first components are displayed
 
 widget.measure_filter_bubble_chart.name=Measure Filter as Bubble Chart
 widget.measure_filter_bubble_chart.description=Displays the result of a pre-configured measure filter as a bubble chart.
index c884f46bb9b9dedfa01b596bf362fbcc75ad1a36..9d85ce988604552d44fa4ae1a218a0136329ad01 100644 (file)
@@ -16,6 +16,8 @@
   <!--[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>
   <% end %>
   <!--<![endif]-->
 </div>
@@ -43,8 +45,8 @@
       .metricsPriority(metrics)
       .options({
         baseUrl: baseUrl + '/dashboard/index/',
-        maxItems: <%= maxItems -%>,
-        maxItemsReachedMessage: '<%= message("widget.measure_filter_histogram.max_items_reached") -%>'
+        displayWorstBestValues: <%= displayWorstBestValues -%>,
+        maxItemsReachedMessage: '<%= message("widget.measure_filter_histogram.max_items_reached", :params => [maxItems]) -%>'
       })
       .render('#<%= containerId -%>');
 
index 13083f8bf89c4452d0e9c2b4a4392a385b75e97e..ebe5440f0ffa033aeef86e9bde25d972b9c2ba7d 100644 (file)
@@ -126,7 +126,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
 
 
     // Show maxResultsReached message
-    this.maxResultsReached(this.options().maxItems === this.components().length);
     if (this.maxResultsReached()) {
       this.maxResultsReachedLabel = this.gWrap.append('text')
           .classed('max-results-reached', true)
@@ -170,9 +169,15 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
 
 
     // Update scales
-    var xDomain = d3.extent(this.components(), function(d) {
-      return widget.getMainMetric(d);
-    });
+    var xDomain;
+    if (this.options().displayWorstBestValues) {
+      var metric = this.metrics()[this.mainMetric];
+      xDomain = [metric.worstValue, metric.bestValue];
+    } else {
+      xDomain = d3.extent(this.components(), function(d) {
+        return widget.getMainMetric(d);
+      });
+    }
     this.x
         .domain(xDomain)
         .range([this.availableWidth / 8, this.availableWidth]);
@@ -245,7 +250,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
     // Show maxResultsReached message
     if (this.maxResultsReached()) {
       this.maxResultsReachedLabel
-          .attr('transform', trans(this.legendWidth(), this.height() - this.margin().bottom));
+          .attr('transform', trans(this.legendWidth(), this.height() - this.margin().bottom - 3));
     }
   };
 
index 6675506407b1e42b0a5cc691fc285165d14ab383..497c90f8a79eef665bd5f9dc08daec4322bf311a 100644 (file)
@@ -48,6 +48,9 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
             .metricsPriority(that.metricsPriority())
             .components(response.components)
             .options(that.options());
+        if (typeof that.widget.maxResultsReached === 'function') {
+          that.widget.maxResultsReached(response.paging.pages > 1);
+        }
         if (that.height()) {
           that.widget.height(that.height());
         }