From 29d4206d4d69d5c36e8153bf1f0f52d47418799c Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 14 Sep 2015 15:51:10 +0200 Subject: SONAR-6708 fix sqale colors on treemap --- .../resources/org/sonar/server/dashboard/widget/treemap.html.erb | 4 ++-- server/sonar-web/src/main/js/libs/widgets/treemap.js | 9 ++++++++- 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); }; -- cgit v1.2.3