@@ -11,10 +11,6 @@ var LINE_SPACING = require('../constants/alignment').LINE_SPACING;
1111
1212// text converter
1313
14- function getSize ( _selection , _dimension ) {
15- return _selection . node ( ) . getBoundingClientRect ( ) [ _dimension ] ;
16- }
17-
1814var FIND_TEX = / ( [ ^ $ ] * ) ( [ $ ] + [ ^ $ ] * [ $ ] + ) ( [ ^ $ ] * ) / ;
1915
2016exports . convertToTspans = function ( _context , gd , _callback ) {
@@ -109,16 +105,17 @@ exports.convertToTspans = function(_context, gd, _callback) {
109105 var g = newSvg . select ( 'g' ) ;
110106 g . attr ( { fill : fill , stroke : fill } ) ;
111107
112- var newSvgW = getSize ( g , 'width' ) ;
113- var newSvgH = getSize ( g , 'height' ) ;
108+ var gBB = g . node ( ) . getBoundingClientRect ( ) ;
109+ var newSvgW = gBB . width ;
110+ var newSvgH = gBB . height ;
114111
115112 var x = + _context . attr ( 'x' ) ;
116113 var y = + _context . attr ( 'y' ) ;
117114
118115 var newX = x - newSvgW *
119116 { start : 0 , middle : 0.5 , end : 1 } [ _context . attr ( 'text-anchor' ) || 'start' ] ;
120117 // font baseline is about 1/4 fontSize below centerline
121- var textHeight = fontSize || getSize ( _context , 'height' ) ;
118+ var textHeight = fontSize || _context . node ( ) . getBoundingClientRect ( ) . height ;
122119 var dy = - textHeight / 4 ;
123120
124121 if ( svgClass [ 0 ] === 'y' ) {
0 commit comments