Index: tracing/tracing/ui/base/chart_base.html |
diff --git a/tracing/tracing/ui/base/chart_base.html b/tracing/tracing/ui/base/chart_base.html |
index ec2f63b2adc682d266dc00c763f5138d0152f801..1a5b943e480b69e18b17c0d9f1b0584ee7438529 100644 |
--- a/tracing/tracing/ui/base/chart_base.html |
+++ b/tracing/tracing/ui/base/chart_base.html |
@@ -34,6 +34,26 @@ found in the LICENSE file. |
<script> |
'use strict'; |
+ |
+tr.exportTo('tr.ui.b', function() { |
+ function getSVGTextWidth(parentNode, text) { |
+ var textNode = document.createElementNS( |
+ 'http://www.w3.org/2000/svg', 'text'); |
+ textNode.setAttributeNS(null, 'x', 0); |
+ textNode.setAttributeNS(null, 'y', 0); |
+ textNode.setAttributeNS(null, 'fill', 'black'); |
+ textNode.appendChild(document.createTextNode(text)); |
+ parentNode.appendChild(textNode); |
+ var widthPx = textNode.getComputedTextLength(); |
+ parentNode.removeChild(textNode); |
+ return widthPx; |
+ } |
+ |
+ return { |
+ getSVGTextWidth: getSVGTextWidth |
+ }; |
+}); |
+ |
Polymer({ |
is: 'tr-ui-b-chart-legend-key', |