@@ -1326,14 +1326,74 @@ describe('funnel hover', function() {
13261326 . then ( done ) ;
13271327 } ) ;
13281328
1329+ it ( 'should turn off percentages with hoveinfo none or skip' , function ( done ) {
1330+ gd = createGraphDiv ( ) ;
1331+
1332+ var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
1333+ mock . data . forEach ( function ( t , i ) {
1334+ t . type = 'funnel' ;
1335+ t . orientation = 'v' ;
1336+ if ( i === 0 ) {
1337+ t . hoverinfo = 'none' ;
1338+ } else {
1339+ t . hoverinfo = 'skip' ;
1340+ }
1341+ } ) ;
1342+
1343+ function _hover ( ) {
1344+ var evt = { xpx : 125 , ypx : 150 } ;
1345+ Fx . hover ( 'graph' , evt , 'xy' ) ;
1346+ }
1347+
1348+ Plotly . plot ( gd , mock )
1349+ . then ( _hover )
1350+ . then ( function ( ) {
1351+ expect ( d3 . selectAll ( 'g.hovertext' ) . size ( ) ) . toBe ( 0 ) ;
1352+ } )
1353+ . catch ( failTest )
1354+ . then ( done ) ;
1355+ } ) ;
1356+
1357+ it ( 'should turn on percentages with hoveinfo all' , function ( done ) {
1358+ gd = createGraphDiv ( ) ;
1359+
1360+ var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
1361+ mock . data . forEach ( function ( t ) {
1362+ t . type = 'funnel' ;
1363+ t . orientation = 'v' ;
1364+ t . hoverinfo = 'all' ;
1365+ } ) ;
1366+
1367+ function _hover ( ) {
1368+ var evt = { xpx : 125 , ypx : 150 } ;
1369+ Fx . hover ( 'graph' , evt , 'xy' ) ;
1370+ }
1371+
1372+ Plotly . plot ( gd , mock )
1373+ . then ( _hover )
1374+ . then ( function ( ) {
1375+ assertHoverLabelContent ( {
1376+ nums : [
1377+ '1\nHover text A\n100% of initial\n100% of previous\n33.3% of total' ,
1378+ '2\nHover text G\n100% of initial\n100% of previous\n33.3% of total' ,
1379+ '1.5\na (hover)\n100% of initial\n100% of previous\n33.3% of total'
1380+ ] ,
1381+ name : [ 'Lines, Marke...' , 'Lines and Text' , 'missing text' ] ,
1382+ axis : '0'
1383+ } ) ;
1384+ } )
1385+ . catch ( failTest )
1386+ . then ( done ) ;
1387+ } ) ;
1388+
13291389 it ( 'should use hovertemplate if specified' , function ( done ) {
13301390 gd = createGraphDiv ( ) ;
13311391
13321392 var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
13331393 mock . data . forEach ( function ( t ) {
13341394 t . type = 'funnel' ;
13351395 t . orientation = 'v' ;
1336- t . hovertemplate = '%{y}<extra></extra>' ;
1396+ t . hovertemplate = 'Value: %{y}<br>Total percentage: %{percentTotal}<br>Initial percentage: %{percentInitial}<br>Previous percentage: %{percentPrevious }<extra></extra>' ;
13371397 } ) ;
13381398
13391399 function _hover ( ) {
@@ -1345,11 +1405,14 @@ describe('funnel hover', function() {
13451405 . then ( _hover )
13461406 . then ( function ( ) {
13471407 assertHoverLabelContent ( {
1348- nums : [ '1' , '2' , '1.5' ] ,
1408+ nums : [
1409+ 'Value: 1\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%' ,
1410+ 'Value: 2\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%' ,
1411+ 'Value: 1.5\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%'
1412+ ] ,
13491413 name : [ '' , '' , '' ] ,
13501414 axis : '0'
13511415 } ) ;
1352- // return Plotly.restyle(gd, 'text', ['APPLE', 'BANANA', 'ORANGE']);
13531416 } )
13541417 . catch ( failTest )
13551418 . then ( done ) ;
0 commit comments