aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-14 15:51:10 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-14 15:51:10 +0200
commit29d4206d4d69d5c36e8153bf1f0f52d47418799c (patch)
tree060fc50ecf6f7a2c5306dfb026173c66f2900dee
parent03f7f009068ff824a48c52aaf5cd5ccd34b3b5e3 (diff)
downloadsonarqube-29d4206d4d69d5c36e8153bf1f0f52d47418799c.tar.gz
sonarqube-29d4206d4d69d5c36e8153bf1f0f52d47418799c.zip
SONAR-6708 fix sqale colors on treemap
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb4
-rw-r--r--server/sonar-web/src/main/js/libs/widgets/treemap.js9
2 files changed, 10 insertions, 3 deletions
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb
index 39ba4bd4302..f6a1fbc2b6b 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb
+++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/treemap.html.erb
@@ -54,8 +54,8 @@
longName: '<%= escape_javascript row.resource.long_name -%>',
qualifier: '<%= escape_javascript row.resource.qualifier -%>',
measures: {
- <%= colorMetric.name -%>: { val: <%= color ? color.value : "null" -%>, fval: '<%= color ? color.formatted_value : "-" -%>', data: '<%= color ? color.formatted_value : "-" -%>' },
- <%= sizeMetric.name -%>: { val: <%= size ? size.value : "null" -%>, fval: '<%= size ? size.formatted_value : "-" -%>', data: '<%= size ? size.formatted_value : "-" -%>' }
+ <%= colorMetric.name -%>: { val: <%= color ? color.value : "null" -%>, fval: '<%= color ? color.formatted_value : "-" -%>' },
+ <%= sizeMetric.name -%>: { val: <%= size ? size.value : "null" -%>, fval: '<%= size ? size.formatted_value : "-" -%>' }
}
},
<% end %>
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 f56f96df623..87fe0548044 100644
--- a/server/sonar-web/src/main/js/libs/widgets/treemap.js
+++ b/server/sonar-web/src/main/js/libs/widgets/treemap.js
@@ -24,6 +24,7 @@
Treemap.prototype.renderTreemap = function () {
var that = this;
var nodes = this.getNodes();
+ this.color = that.getColorScale();
this.cells = this.box.selectAll('.treemap-cell').data(nodes);
this.cells.exit().remove();
var cellsEnter = this.cells.enter().append('div');
@@ -207,7 +208,13 @@
};
Treemap.prototype.getRatingColorScale = function () {
- var domain = ['A', 'B', 'C', 'D', 'E'];
+ var domain = [1, 2, 3, 4, 5];
+ if (this.components().length > 0) {
+ var colorMetricSample = this.colorMetric.value(_.first(this.components()));
+ if (typeof colorMetricSample === 'string') {
+ domain = ['A', 'B', 'C', 'D', 'E'];
+ }
+ }
return d3.scale.ordinal().domain(domain).range(this.colors5r);
};