@@ -11,10 +11,6 @@ var LINE_SPACING = require('../constants/alignment').LINE_SPACING;
11
11
12
12
// text converter
13
13
14
- function getSize ( _selection , _dimension ) {
15
- return _selection . node ( ) . getBoundingClientRect ( ) [ _dimension ] ;
16
- }
17
-
18
14
var FIND_TEX = / ( [ ^ $ ] * ) ( [ $ ] + [ ^ $ ] * [ $ ] + ) ( [ ^ $ ] * ) / ;
19
15
20
16
exports . convertToTspans = function ( _context , gd , _callback ) {
@@ -109,16 +105,17 @@ exports.convertToTspans = function(_context, gd, _callback) {
109
105
var g = newSvg . select ( 'g' ) ;
110
106
g . attr ( { fill : fill , stroke : fill } ) ;
111
107
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 ;
114
111
115
112
var x = + _context . attr ( 'x' ) ;
116
113
var y = + _context . attr ( 'y' ) ;
117
114
118
115
var newX = x - newSvgW *
119
116
{ start : 0 , middle : 0.5 , end : 1 } [ _context . attr ( 'text-anchor' ) || 'start' ] ;
120
117
// font baseline is about 1/4 fontSize below centerline
121
- var textHeight = fontSize || getSize ( _context , 'height' ) ;
118
+ var textHeight = fontSize || _context . node ( ) . getBoundingClientRect ( ) . height ;
122
119
var dy = - textHeight / 4 ;
123
120
124
121
if ( svgClass [ 0 ] === 'y' ) {
0 commit comments