@@ -339,57 +339,52 @@ 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
+
347
+ if ( ! text || Array . isArray ( text ) ) {
348
+ // isArray test handles the case of (intentionally) missing
349
+ // or empty text within a text array
350
+ p . 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
+ p . 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 ( this . parentNode ) ,
375
+ tspans = p . 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 : p . attr ( 'x' ) , y : p . attr ( 'y' ) } ) ;
387
+ }
393
388
} ) ;
394
389
} ;
395
390
0 commit comments