diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 14:19:57 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 14:19:57 +0200 |
commit | b525a1a435a402a47f178af93a235c83c3323c35 (patch) | |
tree | 28979c4215fd3d788f6f8e13b8bfb9c6f53408c3 /server/sonar-web | |
parent | c884d6186069ec70c4936dc084a2bc1b705e7928 (diff) | |
download | sonarqube-b525a1a435a402a47f178af93a235c83c3323c35.tar.gz sonarqube-b525a1a435a402a47f178af93a235c83c3323c35.zip |
SONAR-6687 Treemap should not show items with zero size
Diffstat (limited to 'server/sonar-web')
-rw-r--r-- | server/sonar-web/src/main/js/libs/widgets/treemap.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/libs/widgets/treemap.js b/server/sonar-web/src/main/js/libs/widgets/treemap.js index 87fe0548044..a4007265382 100644 --- a/server/sonar-web/src/main/js/libs/widgets/treemap.js +++ b/server/sonar-web/src/main/js/libs/widgets/treemap.js @@ -13,6 +13,14 @@ Treemap.prototype.sizeHigh = 18; + Treemap.prototype.filterComponents = function () { + var that = this, + components = this.components().filter(function (d) { + return that.sizeMetric.value(d) != null; + }); + this.components(components); + }; + Treemap.prototype.getNodes = function () { return this.treemap .nodes({ children: this.components() }) @@ -23,6 +31,13 @@ Treemap.prototype.renderTreemap = function () { var that = this; + this.filterComponents(); + if (!this.components().length) { + this.maxResultsReachedLabel + .text(window.t('treemap.all_measures_undefined')) + .style('display', 'block'); + return; + } var nodes = this.getNodes(); this.color = that.getColorScale(); this.cells = this.box.selectAll('.treemap-cell').data(nodes); @@ -251,10 +266,12 @@ Treemap.prototype.update = function () { this.width(this.box.property('offsetWidth')); this.height(this.width() / 100.0 * this.options().heightInPercents); - this.box.style('height', (this.height()) + 'px'); - this.treemap.size([this.width(), this.height()]); - this.cells.data(this.getNodes()); - return this.positionCells(); + if (this.components().length) { + this.box.style('height', (this.height()) + 'px'); + this.treemap.size([this.width(), this.height()]); + this.cells.data(this.getNodes()); + this.positionCells(); + } }; Treemap.prototype.formatComponents = function (data) { |