From: Jean-Baptiste Lievremont Date: Mon, 4 Aug 2014 12:56:36 +0000 (+0200) Subject: SONAR-5004 Do not display bubble chart when all values for one axis are null/non... X-Git-Tag: 4.5-RC1~275 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=62aa23863d60b66aea4e027a1d8899cb10142560;p=sonarqube.git SONAR-5004 Do not display bubble chart when all values for one axis are null/non available --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb index ecd2bdb29d1..d3dd9d7d3f1 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/bubbleChart.html.erb @@ -74,7 +74,9 @@ .options({ baseUrl: baseUrl + '/dashboard/index/', xLog: <%= xLog -%>, - yLog: <%= yLog -%> + yLog: <%= yLog -%>, + noData: '<%= message('no_data') -%>', + noMainMetric: '<%= message('widget.measure_filter.no_main_metric') -%>' }) .render('#<%= containerId -%>'); @@ -84,4 +86,3 @@ })(); - diff --git a/server/sonar-web/src/main/js/widgets/bubble-chart.js b/server/sonar-web/src/main/js/widgets/bubble-chart.js index de34819fdd5..d4b3feb87a3 100644 --- a/server/sonar-web/src/main/js/widgets/bubble-chart.js +++ b/server/sonar-web/src/main/js/widgets/bubble-chart.js @@ -70,9 +70,15 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; container = d3.select(container); - var validData = this.components().reduce(function(p, c) { - return p && !!c.measures[widget.metricsPriority()[0]] && !!c.measures[widget.metricsPriority()[1]]; - }, true); + var noInvalidEntry = true, + atLeastOneValueOnX = false, + atLeastOneValueOnY = false; + this.components().forEach(function validateComponent(component) { + noInvalidEntry &= (!!component.measures[widget.metricsPriority()[0]] && !!component.measures[widget.metricsPriority()[1]]); + atLeastOneValueOnX |= (component.measures[widget.metricsPriority()[0]] || {}).fval != '-'; + atLeastOneValueOnY |= (component.measures[widget.metricsPriority()[1]] || {}).fval != '-'; + }); + var validData = !!noInvalidEntry && !!atLeastOneValueOnX && !!atLeastOneValueOnY; if (!validData) { container.text(this.options().noMainMetric);