From cf8127c1b33fd0c066b0ec3ad9c970865fd1ffec Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Sep 2015 16:45:39 +0200 Subject: [PATCH] SONAR-6852 Improve display of package names inside word cloud widget --- .../sonar-web/src/main/js/libs/widgets/word-cloud.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/libs/widgets/word-cloud.js b/server/sonar-web/src/main/js/libs/widgets/word-cloud.js index c12e02390e4..15fd7e9e96e 100644 --- a/server/sonar-web/src/main/js/libs/widgets/word-cloud.js +++ b/server/sonar-web/src/main/js/libs/widgets/word-cloud.js @@ -13,12 +13,21 @@ WordCloud.prototype.sizeLow = 10; + WordCloud.prototype.formatDirectory = function (path) { + var dirs = path.split('/'); + if (dirs.length > 2) { + return '.../' + dirs[dirs.length - 1]; + } else { + return path; + } + }; + WordCloud.prototype.renderWords = function () { var that = this; var words = this.wordContainer.selectAll('.cloud-word').data(this.components()), wordsEnter = words.enter().append('a').classed('cloud-word', true); wordsEnter.text(function (d) { - return d.name; + return d.qualifier === 'DIR' ? that.formatDirectory(d.name) : d.name; }); wordsEnter.attr('href', function (d) { return that.options().baseUrl + '?id=' + encodeURIComponent(d.key); -- 2.39.5