From 62aa23863d60b66aea4e027a1d8899cb10142560 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Mon, 4 Aug 2014 14:56:36 +0200 Subject: [PATCH] SONAR-5004 Do not display bubble chart when all values for one axis are null/non available --- .../sonar/plugins/core/widgets/bubbleChart.html.erb | 5 +++-- server/sonar-web/src/main/js/widgets/bubble-chart.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) 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); -- 2.39.5