Index: tracing/tracing/ui/base/name_bar_chart.html |
diff --git a/tracing/tracing/ui/base/name_bar_chart.html b/tracing/tracing/ui/base/name_bar_chart.html |
index 8d594fb5c1202a4209f5cc8243e715a77ee08d14..b142f257bd5654e0afd6eee8663790b13e2fe551 100644 |
--- a/tracing/tracing/ui/base/name_bar_chart.html |
+++ b/tracing/tracing/ui/base/name_bar_chart.html |
@@ -5,7 +5,7 @@ Use of this source code is governed by a BSD-style license that can be |
found in the LICENSE file. |
--> |
-<link rel="import" href="/tracing/base/range.html"> |
+<link rel="import" href="/tracing/base/raf.html"> |
<link rel="import" href="/tracing/ui/base/bar_chart.html"> |
<link rel="import" href="/tracing/ui/base/d3.html"> |
@@ -25,7 +25,6 @@ tr.exportTo('tr.ui.b', function() { |
BarChart.prototype.decorate.call(this); |
Polymer.dom(this).classList.remove('bar-chart'); |
Polymer.dom(this).classList.add('name-bar-chart'); |
- this.bottomMargin_ = 40; |
}, |
isDatumFieldSeries_: function(fieldName) { |
@@ -36,12 +35,6 @@ tr.exportTo('tr.ui.b', function() { |
return index; |
}, |
- getMargin_: function() { |
- var margin = BarChart.prototype.getMargin_.call(this); |
- margin.bottom = this.bottomMargin_; |
- return margin; |
- }, |
- |
updateXAxis_: function(xAxis) { |
xAxis.selectAll('*').remove(); |
var y = this.chartAreaSize.height + 10; |
@@ -68,8 +61,10 @@ tr.exportTo('tr.ui.b', function() { |
// If the nameTexts extend past the bottom of the chart, then increase |
// this.bottomMargin_ and re-render. |
- var bottomMargin = this.bottomMargin_; |
- window.requestAnimationFrame(function() { |
+ // TODO(benjhayden): Refactor with the code that is very similar to this |
+ // in chart_base_2d. |
+ var bottomMargin = this.margin.bottom; |
+ tr.b.requestAnimationFrame(function() { |
nameTexts[0].forEach(function(t) { |
var box = t.getBBox(); |
// When the text is rotated, its height is the hypotenuse |
@@ -77,14 +72,15 @@ tr.exportTo('tr.ui.b', function() { |
// triangle W. The bottomMargin must be equal to a side of H plus a |
// side of W. |
var h = Math.cos(Math.PI / 4) * (box.height + box.width); |
- bottomMargin = Math.max(this.bottomMargin_, h); |
+ bottomMargin = Math.max(bottomMargin, h); |
}, this); |
- if (Math.round(bottomMargin) !== Math.round(this.bottomMargin_)) { |
- this.bottomMargin_ = bottomMargin; |
+ bottomMargin = parseInt(Math.ceil(bottomMargin)); |
+ if (bottomMargin > this.margin.bottom) { |
+ this.margin.bottom = bottomMargin; |
this.updateContents_(); |
} |
- }.bind(this)); |
+ }, this); |
} |
}; |