@@ -925,15 +925,10 @@ function createHoverText(hoverData, opts, gd) {
925925 if ( d . nameOverride !== undefined ) d . name = d . nameOverride ;
926926
927927 if ( d . name ) {
928- // strip out our pseudo-html elements from d.name (if it exists at all)
929- name = svgTextUtils . plainText ( d . name || '' ) ;
930-
931- var nameLength = Math . round ( d . nameLength ) ;
932-
933- if ( nameLength > - 1 && name . length > nameLength ) {
934- if ( nameLength > 3 ) name = name . substr ( 0 , nameLength - 3 ) + '...' ;
935- else name = name . substr ( 0 , nameLength ) ;
936- }
928+ name = svgTextUtils . plainText ( d . name || '' , {
929+ len : d . nameLength ,
930+ allowedTags : [ 'br' , 'sub' , 'sup' , 'b' , 'i' , 'em' ]
931+ } ) ;
937932 }
938933
939934 if ( d . zLabel !== undefined ) {
@@ -995,6 +990,7 @@ function createHoverText(hoverData, opts, gd) {
995990
996991 var tx2 = g . select ( 'text.name' ) ;
997992 var tx2width = 0 ;
993+ var tx2height = 0 ;
998994
999995 // secondary label for non-empty 'name'
1000996 if ( name && name !== text ) {
@@ -1006,18 +1002,20 @@ function createHoverText(hoverData, opts, gd) {
10061002 . attr ( 'data-notex' , 1 )
10071003 . call ( svgTextUtils . positionText , 0 , 0 )
10081004 . call ( svgTextUtils . convertToTspans , gd ) ;
1009- tx2width = tx2 . node ( ) . getBoundingClientRect ( ) . width + 2 * HOVERTEXTPAD ;
1010- }
1011- else {
1005+
1006+ var t2bb = tx2 . node ( ) . getBoundingClientRect ( ) ;
1007+ tx2width = t2bb . width + 2 * HOVERTEXTPAD ;
1008+ tx2height = t2bb . height + 2 * HOVERTEXTPAD ;
1009+ } else {
10121010 tx2 . remove ( ) ;
10131011 g . select ( 'rect' ) . remove ( ) ;
10141012 }
10151013
1016- g . select ( 'path' )
1017- . style ( {
1018- fill : numsColor ,
1019- stroke : contrastColor
1020- } ) ;
1014+ g . select ( 'path' ) . style ( {
1015+ fill : numsColor ,
1016+ stroke : contrastColor
1017+ } ) ;
1018+
10211019 var tbb = tx . node ( ) . getBoundingClientRect ( ) ;
10221020 var htx = d . xa . _offset + ( d . x0 + d . x1 ) / 2 ;
10231021 var hty = d . ya . _offset + ( d . y0 + d . y1 ) / 2 ;
@@ -1028,7 +1026,7 @@ function createHoverText(hoverData, opts, gd) {
10281026
10291027 d . ty0 = outerTop - tbb . top ;
10301028 d . bx = tbb . width + 2 * HOVERTEXTPAD ;
1031- d . by = tbb . height + 2 * HOVERTEXTPAD ;
1029+ d . by = Math . max ( tbb . height + 2 * HOVERTEXTPAD , tx2height ) ;
10321030 d . anchor = 'start' ;
10331031 d . txwidth = tbb . width ;
10341032 d . tx2width = tx2width ;
0 commit comments