From: Stas Vilchik Date: Fri, 20 Dec 2013 07:01:06 +0000 (+0600) Subject: SONAR-3762 Provide a new Histogram widget to display a measure filter X-Git-Tag: 4.2~877 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40afe633ae996f15f3d34b0f41d562e0dbd68059;p=sonarqube.git SONAR-3762 Provide a new Histogram widget to display a measure filter Latest updates --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb index 9d85ce98860..27816a9722e 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_histogram.html.erb @@ -15,9 +15,7 @@ <% if chartTitle %> -

<%= h(chartTitle) -%>

- <% else %> -

<%= h widget_properties["metric"].short_name -%>

+

<%= h(chartTitle) -%>

<% end %> diff --git a/sonar-server/src/main/webapp/javascripts/widgets/histogram.js b/sonar-server/src/main/webapp/javascripts/widgets/histogram.js index ebe5440f0ff..fc998e39d58 100644 --- a/sonar-server/src/main/webapp/javascripts/widgets/histogram.js +++ b/sonar-server/src/main/webapp/javascripts/widgets/histogram.js @@ -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