]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5207 Treemap feedback
authorStas Vilchik <vilchiks@gmail.com>
Fri, 11 Jul 2014 09:18:12 +0000 (15:18 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 11 Jul 2014 09:19:42 +0000 (15:19 +0600)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
server/sonar-server/src/main/coffee/widgets/treemap.coffee
server/sonar-server/src/main/less/icons.less
server/sonar-server/src/main/less/style.less
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 36334a8e333a84094fba550a630ece728ce96cd5..53911880335edbf470558072a446bdc6cb5f4788 100644 (file)
@@ -45,7 +45,8 @@
           maxItems: <%= maxItems -%>,
           maxItemsReachedMessage: '<%= message("widget.measure_filter_histogram.max_items_reached", :params => [maxItems]) -%>',
           baseUrl: baseUrl + '/dashboard/index/',
-          noData: '<%= message('no_data') -%>'
+          noData: '<%= message('no_data') -%>',
+          resource: '<%= filter.name -%>'
         })
         .render('#<%= containerId -%>');
 
index 55c2c87796a3ae20e74bdfe37dabbe20c0fa24ee..313e13f2c0dcb4512d535bff6ed38ffcfcb8e966 100644 (file)
@@ -69,7 +69,8 @@
         maxItems: <%= maxItems -%>,
         maxItemsReachedMessage: '<%= message("widget.measure_filter_histogram.max_items_reached", :params => [maxItems]) -%>',
         baseUrl: baseUrl + '/dashboard/index/',
-        noData: '<%= message('no_data') -%>'
+        noData: '<%= message('no_data') -%>',
+        resource: '<%= @resource.name -%>'
       })
       .render('#<%= containerId -%>');
 
index 1a55e9f273918e9c7d50e929d68ec05ead4da8c6..075eabe43e3aa60a67cf3a27e8835bb38fdd67d1 100644 (file)
@@ -22,6 +22,7 @@ class Treemap extends window.SonarWidgets.BaseWidget
     cellsEnter = @cells.enter().append 'div'
     cellsEnter.classed 'treemap-cell', true
     cellsEnter.append('div').classed 'treemap-inner', true
+    cellsEnter.append('a').classed 'treemap-link', true
 
     @cells.attr 'title', (d) => @tooltip d
     @cells.style 'background-color', (d) =>
@@ -37,6 +38,13 @@ class Treemap extends window.SonarWidgets.BaseWidget
         "#{prefix}<br>#{d.longName.substr prefixLength}"
       else d.longName
 
+    @cellsLink = @box.selectAll('.treemap-link').data nodes
+    @cellsLink.html '<i class="icon-link"></i>'
+    @cellsLink.attr 'href', (d) =>
+      url = @options().baseUrl + encodeURIComponent(d.key)
+      url += '?metric=' + encodeURIComponent(@colorMetric.key) if d.qualifier == 'CLA' || d.qualifier == 'FIL'
+      url
+
     @attachEvents cellsEnter
 
     @maxResultsReachedLabel.style 'display', if @maxResultsReached() then 'block' else 'none'
@@ -52,13 +60,6 @@ class Treemap extends window.SonarWidgets.BaseWidget
 
   attachEvents: (cells) ->
     cells.on 'click', (d) => @requestChildren d
-    cells.on 'dblclick', (d) => @openDashboard d
-
-
-  openDashboard: (d) ->
-    url = @options().baseUrl + encodeURIComponent(d.key)
-    url += '?metric=' + encodeURIComponent(@colorMetric.key) if d.qualifier == 'CLA' || d.qualifier == 'FIL'
-    window.location = url
 
 
   positionCells: ->
@@ -69,8 +70,9 @@ class Treemap extends window.SonarWidgets.BaseWidget
     @cells.style 'height', (d) -> "#{d.dy}px"
     @cells.style 'line-height', (d) -> "#{d.dy}px"
     @cells.style 'font-size', (d) => "#{@size (d.dx / d.longName.length)}px"
-    @cells.classed 'treemap-cell-small', (d) ->
-      (d.dx / d.longName.length) < 1 || d.dy < 40
+    @cellsLink.style 'font-size', (d) => "#{@sizeLink Math.min(d.dx, d.dy)}px"
+    @cells.classed 'treemap-cell-small', (d) -> (d.dx / d.longName.length) < 1 || d.dy < 40
+    @cells.classed 'treemap-cell-very-small', (d) -> d.dx < 24 || d.dy < 24
 
 
   renderLegend: (box) ->
@@ -92,6 +94,8 @@ class Treemap extends window.SonarWidgets.BaseWidget
     breadcrumbs = @breadcrumbsBox.selectAll('.treemap-breadcrumbs-item').data @breadcrumbs
     breadcrumbs.exit().remove()
     breadcrumbsEnter = breadcrumbs.enter().append('span').classed 'treemap-breadcrumbs-item', true
+    breadcrumbsEnter.attr 'title', (d) =>
+      if d.longName? then d.longName else @options().resource
     breadcrumbsEnter.append('i').classed('icon-chevron-right', true).style 'display', (d, i) ->
       if i > 0 then 'inline' else 'none'
     breadcrumbsEnter.append('i').attr 'class', (d) ->
@@ -154,8 +158,12 @@ class Treemap extends window.SonarWidgets.BaseWidget
     @color = @getColorScale()
 
     @size = d3.scale.linear().domain([3, 15]).range([@sizeLow, @sizeHigh]).clamp true
+    @sizeLink = d3.scale.linear().domain([60, 100]).range([12, 14]).clamp true
 
     @treemap = d3.layout.treemap()
+    @treemap.sort (a, b) -> a.value - b.value
+    @treemap.round true
+
     @treemap.value (d) => @sizeMetric.value d
 
     @maxResultsReachedLabel = box.append('div').text @options().maxItemsReachedMessage
index c7ff41c31c317a26a8034304e7cbf0a79afedcd1..014b1d0ade4a34d682b2cf04aa290e9d570a6e72 100644 (file)
@@ -378,9 +378,6 @@ a[class^="icon-"], a[class*=" icon-"] {
   content: "\f122";
   font-size: @iconSmallFontSize;
 }
-.icon-link:before {
-  content: "\f0c1";
-}
 .icon-inheritance:before {
   content: "\f126";
 }
index 21ad9a7d64170ed3a6797697c2ad52e481877713..93f7217dd7631b3cf56407387dce7d3f98235628 100644 (file)
@@ -2843,21 +2843,33 @@ div.rule-title {
   white-space: nowrap;
 }
 
-.sonar-d3 .treemap-dashboard {
+.sonar-d3 .treemap-link {
   position: absolute;
   z-index: 2;
   top: 5px; right: 5px;
-  line-height: 16px;
-  color: inherit;
+  line-height: @iconSmallFontSize;
+  color: #fff;
   opacity: 0.5;
 
   &:hover { opacity: 1; }
 }
 
+.sonar-d3 .treemap-link i,
+.sonar-d3 .treemap-link i:before {
+  vertical-align: top;
+  font-size: inherit;
+  line-height: inherit;
+}
+
 .sonar-d3 .treemap-cell-small {
   .treemap-inner { display: none; }
 }
 
+.sonar-d3 .treemap-cell-very-small {
+  .treemap-inner { display: none; }
+  .treemap-link { display: none; }
+}
+
 .sonar-d3 .treemap-breadcrumbs {
   margin-top: 10px;
   padding-top: 7px;
index 3a43b6dc3937554b07e55376d58d743dc7d24110..e4c8858c6acb67b9e4c1dfea06ba5ec6b3b03283 100644 (file)
@@ -1961,8 +1961,7 @@ provisioning.no_analysis=No analysis has been performed since creation. The only
 # TREEMAP
 #
 #------------------------------------------------------------------------------
-treemap.click_help=Left click to zoom in. Right click to zoom out.
-treemap.bootom_level_reached=Zooming in is not possible as you have reached the bottom level
+treemap.open_dashboard=Open Dashboard
 
 
 #------------------------------------------------------------------------------