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) =>
"#{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'
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: ->
@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) ->
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) ->
@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
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;