aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-07-30 09:50:48 +0200
committerStas Vilchik <vilchiks@gmail.com>2014-07-30 09:50:57 +0200
commit8120006732621bfcc060a5d6a087c187f5ea936f (patch)
tree3058a98b9377941bf08451b7431a6d26e2b8c542 /server/sonar-web
parentb297ce0e68c81c92f2773f20e4fa0b558d55f054 (diff)
downloadsonarqube-8120006732621bfcc060a5d6a087c187f5ea936f.tar.gz
sonarqube-8120006732621bfcc060a5d6a087c187f5ea936f.zip
SONAR-5507 Improve bubble chart rendering when there is only one component
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/widgets/bubble-chart.js70
1 files changed, 42 insertions, 28 deletions
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 edafc4c6f66..de34819fdd5 100644
--- a/server/sonar-web/src/main/js/widgets/bubble-chart.js
+++ b/server/sonar-web/src/main/js/widgets/bubble-chart.js
@@ -128,23 +128,29 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.y = this.yLog() ? d3.scale.log() : d3.scale.linear();
this.size = d3.scale.linear();
- this.x
- .domain(d3.extent(this.components(), function (d) {
- return widget.getXMetric(d);
- }))
- .range([0, this.availableWidth]);
-
- this.y
- .domain(d3.extent(this.components(), function (d) {
- return widget.getYMetric(d);
- }))
- .range([this.availableHeight, 0]);
-
- this.size
- .domain(d3.extent(this.components(), function (d) {
- return widget.getSizeMetric(d);
- }))
- .range([5, 45]);
+ this.x.range([0, this.availableWidth]);
+ this.y.range([this.availableHeight, 0]);
+ this.size.range([5, 45]);
+
+ if (this.components().length > 1) {
+ this.x.domain(d3.extent(this.components(), function (d) {
+ return widget.getXMetric(d);
+ }));
+ this.y.domain(d3.extent(this.components(), function (d) {
+ return widget.getYMetric(d);
+ }));
+ this.size.domain(d3.extent(this.components(), function (d) {
+ return widget.getSizeMetric(d);
+ }));
+ } else {
+ var singleComponent = this.components()[0],
+ xm = this.getXMetric(singleComponent),
+ ym = this.getYMetric(singleComponent),
+ sm = this.getSizeMetric(singleComponent);
+ this.x.domain([xm * 0.8, xm * 1.2]);
+ this.y.domain([ym * 0.8, ym * 1.2]);
+ this.size.domain([sm * 0.8, sm * 1.2]);
+ }
// Create bubbles
@@ -318,17 +324,25 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Update scales
- this.x
- .domain(d3.extent(this.components(), function (d) {
- return widget.getXMetric(d);
- }))
- .range([0, this.availableWidth]);
-
- this.y
- .domain(d3.extent(this.components(), function (d) {
- return widget.getYMetric(d);
- }))
- .range([this.availableHeight, 0]);
+ this.x.range([0, this.availableWidth]);
+ this.y.range([this.availableHeight, 0]);
+
+ if (this.components().length > 1) {
+ this.x.domain(d3.extent(this.components(), function (d) {
+ return widget.getXMetric(d);
+ }));
+ this.y.domain(d3.extent(this.components(), function (d) {
+ return widget.getYMetric(d);
+ }))
+ } else {
+ var singleComponent = this.components()[0],
+ xm = this.getXMetric(singleComponent),
+ ym = this.getYMetric(singleComponent),
+ sm = this.getSizeMetric(singleComponent);
+ this.x.domain([xm * 0.8, xm * 1.2]);
+ this.y.domain([ym * 0.8, ym * 1.2]);
+ this.size.domain([sm * 0.8, sm * 1.2]);
+ }
if (this.x.domain()[0] === 0 && this.x.domain()[1] === 0) {