@@ -339,57 +339,51 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
339
339
// draw text at points
340
340
var TEXTOFFSETSIGN = { start : 1 , end : - 1 , middle : 0 , bottom : 1 , top : - 1 } ,
341
341
LINEEXPAND = 1.3 ;
342
-
343
- drawing . singleTextPointStyle = function ( d , sel , trace ) {
344
- var el = sel . node ( ) ,
345
- text = d . tx || trace . text ;
346
-
347
- if ( ! text || Array . isArray ( text ) ) {
348
- // isArray test handles the case of (intentionally) missing
349
- // or empty text within a text array
350
- sel . remove ( ) ;
351
- return ;
352
- }
353
-
354
- var pos = d . tp || trace . textposition ,
355
- v = pos . indexOf ( 'top' ) !== - 1 ? 'top' :
356
- pos . indexOf ( 'bottom' ) !== - 1 ? 'bottom' : 'middle' ,
357
- h = pos . indexOf ( 'left' ) !== - 1 ? 'end' :
358
- pos . indexOf ( 'right' ) !== - 1 ? 'start' : 'middle' ,
359
- fontSize = d . ts || trace . textfont . size ,
360
- // if markers are shown, offset a little more than
361
- // the nominal marker size
362
- // ie 2/1.6 * nominal, bcs some markers are a bit bigger
363
- r = d . mrc ? ( d . mrc / 0.8 + 1 ) : 0 ;
364
-
365
- fontSize = ( isNumeric ( fontSize ) && fontSize > 0 ) ? fontSize : 0 ;
366
-
367
- sel . call ( drawing . font ,
368
- d . tf || trace . textfont . family ,
369
- fontSize ,
370
- d . tc || trace . textfont . color )
371
- . attr ( 'text-anchor' , h )
372
- . text ( text )
373
- . call ( svgTextUtils . convertToTspans ) ;
374
- var pgroup = d3 . select ( el . parentNode ) ,
375
- tspans = sel . selectAll ( 'tspan.line' ) ,
376
- numLines = ( ( tspans [ 0 ] . length || 1 ) - 1 ) * LINEEXPAND + 1 ,
377
- dx = TEXTOFFSETSIGN [ h ] * r ,
378
- dy = fontSize * 0.75 + TEXTOFFSETSIGN [ v ] * r +
379
- ( TEXTOFFSETSIGN [ v ] - 1 ) * numLines * fontSize / 2 ;
380
-
381
- // fix the overall text group position
382
- pgroup . attr ( 'transform' , 'translate(' + dx + ',' + dy + ')' ) ;
383
-
384
- // then fix multiline text
385
- if ( numLines > 1 ) {
386
- tspans . attr ( { x : sel . attr ( 'x' ) , y : sel . attr ( 'y' ) } ) ;
387
- }
388
- } ;
389
-
390
342
drawing . textPointStyle = function ( s , trace ) {
391
343
s . each ( function ( d ) {
392
- drawing . singleTextPointStyle ( d , d3 . select ( this ) , trace ) ;
344
+ var p = d3 . select ( this ) ,
345
+ text = d . tx || trace . text ;
346
+ if ( ! text || Array . isArray ( text ) ) {
347
+ // isArray test handles the case of (intentionally) missing
348
+ // or empty text within a text array
349
+ p . remove ( ) ;
350
+ return ;
351
+ }
352
+
353
+ var pos = d . tp || trace . textposition ,
354
+ v = pos . indexOf ( 'top' ) !== - 1 ? 'top' :
355
+ pos . indexOf ( 'bottom' ) !== - 1 ? 'bottom' : 'middle' ,
356
+ h = pos . indexOf ( 'left' ) !== - 1 ? 'end' :
357
+ pos . indexOf ( 'right' ) !== - 1 ? 'start' : 'middle' ,
358
+ fontSize = d . ts || trace . textfont . size ,
359
+ // if markers are shown, offset a little more than
360
+ // the nominal marker size
361
+ // ie 2/1.6 * nominal, bcs some markers are a bit bigger
362
+ r = d . mrc ? ( d . mrc / 0.8 + 1 ) : 0 ;
363
+
364
+ fontSize = ( isNumeric ( fontSize ) && fontSize > 0 ) ? fontSize : 0 ;
365
+
366
+ p . call ( drawing . font ,
367
+ d . tf || trace . textfont . family ,
368
+ fontSize ,
369
+ d . tc || trace . textfont . color )
370
+ . attr ( 'text-anchor' , h )
371
+ . text ( text )
372
+ . call ( svgTextUtils . convertToTspans ) ;
373
+ var pgroup = d3 . select ( this . parentNode ) ,
374
+ tspans = p . selectAll ( 'tspan.line' ) ,
375
+ numLines = ( ( tspans [ 0 ] . length || 1 ) - 1 ) * LINEEXPAND + 1 ,
376
+ dx = TEXTOFFSETSIGN [ h ] * r ,
377
+ dy = fontSize * 0.75 + TEXTOFFSETSIGN [ v ] * r +
378
+ ( TEXTOFFSETSIGN [ v ] - 1 ) * numLines * fontSize / 2 ;
379
+
380
+ // fix the overall text group position
381
+ pgroup . attr ( 'transform' , 'translate(' + dx + ',' + dy + ')' ) ;
382
+
383
+ // then fix multiline text
384
+ if ( numLines > 1 ) {
385
+ tspans . attr ( { x : p . attr ( 'x' ) , y : p . attr ( 'y' ) } ) ;
386
+ }
393
387
} ) ;
394
388
} ;
395
389
0 commit comments