@@ -2082,6 +2082,45 @@ describe('hover info', function() {
2082
2082
. catch ( failTest )
2083
2083
. then ( done ) ;
2084
2084
} ) ;
2085
+
2086
+ it ( 'should honor *hoverlabel.align (centered label case)' , function ( done ) {
2087
+ var gd = createGraphDiv ( ) ;
2088
+
2089
+ function _assert ( msg , exp ) {
2090
+ var tx = d3 . select ( 'g.hovertext' ) . select ( 'text.nums' ) ;
2091
+ expect ( tx . attr ( 'text-anchor' ) ) . toBe ( exp . textAnchor , 'text anchor|' + msg ) ;
2092
+ expect ( Number ( tx . attr ( 'x' ) ) ) . toBeWithin ( exp . posX , 3 , 'x position|' + msg ) ;
2093
+ delete gd . _hoverdata ;
2094
+ }
2095
+
2096
+ Plotly . plot ( gd , [ {
2097
+ x : [ 'giraffes' ] ,
2098
+ y : [ 5 ] ,
2099
+ name : 'LA Zoo' ,
2100
+ type : 'bar' ,
2101
+ text : [ 'Way tooooo long hover info!' ] ,
2102
+ hoverinfo : 'all'
2103
+ } ] , {
2104
+ margin : { l : 0 , t : 0 , b : 0 , r : 0 } ,
2105
+ hovermode : 'closest' ,
2106
+ width : 400 ,
2107
+ height : 400
2108
+ } )
2109
+ . then ( function ( ) { _hoverNatural ( gd , 200 , 200 ) ; } )
2110
+ . then ( function ( ) { _assert ( 'base' , { textAnchor : 'middle' , posX : - 24.3 } ) ; } )
2111
+ . then ( function ( ) {
2112
+ return Plotly . relayout ( gd , 'hoverlabel.align' , 'left' ) ;
2113
+ } )
2114
+ . then ( function ( ) { _hoverNatural ( gd , 200 , 200 ) ; } )
2115
+ . then ( function ( ) { _assert ( 'align:left' , { textAnchor : 'start' , posX : - 105.7 } ) ; } )
2116
+ . then ( function ( ) {
2117
+ return Plotly . restyle ( gd , 'hoverlabel.align' , 'right' ) ;
2118
+ } )
2119
+ . then ( function ( ) { _hoverNatural ( gd , 200 , 200 ) ; } )
2120
+ . then ( function ( ) { _assert ( 'align:right' , { textAnchor : 'end' , posX : 57 } ) ; } )
2121
+ . catch ( failTest )
2122
+ . then ( done ) ;
2123
+ } ) ;
2085
2124
} ) ;
2086
2125
2087
2126
describe ( 'hover info on stacked subplots' , function ( ) {
0 commit comments