@@ -1326,14 +1326,76 @@ 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+ assertHoverLabelContent ( {
1352+ isEmpty : true
1353+ } ) ;
1354+ } )
1355+ . catch ( failTest )
1356+ . then ( done ) ;
1357+ } ) ;
1358+
1359+ it ( 'should turn on percentages with hoveinfo all' , function ( done ) {
1360+ gd = createGraphDiv ( ) ;
1361+
1362+ var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
1363+ mock . data . forEach ( function ( t ) {
1364+ t . type = 'funnel' ;
1365+ t . orientation = 'v' ;
1366+ t . hoverinfo = 'all' ;
1367+ } ) ;
1368+
1369+ function _hover ( ) {
1370+ var evt = { xpx : 125 , ypx : 150 } ;
1371+ Fx . hover ( 'graph' , evt , 'xy' ) ;
1372+ }
1373+
1374+ Plotly . plot ( gd , mock )
1375+ . then ( _hover )
1376+ . then ( function ( ) {
1377+ assertHoverLabelContent ( {
1378+ nums : [
1379+ '1\nHover text A\n100% of initial\n100% of previous\n33.3% of total' ,
1380+ '2\nHover text G\n100% of initial\n100% of previous\n33.3% of total' ,
1381+ '1.5\na (hover)\n100% of initial\n100% of previous\n33.3% of total'
1382+ ] ,
1383+ name : [ 'Lines, Marke...' , 'Lines and Text' , 'missing text' ] ,
1384+ axis : '0'
1385+ } ) ;
1386+ } )
1387+ . catch ( failTest )
1388+ . then ( done ) ;
1389+ } ) ;
1390+
13291391 it ( 'should use hovertemplate if specified' , function ( done ) {
13301392 gd = createGraphDiv ( ) ;
13311393
13321394 var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
13331395 mock . data . forEach ( function ( t ) {
13341396 t . type = 'funnel' ;
13351397 t . orientation = 'v' ;
1336- t . hovertemplate = '%{y}<extra></extra>' ;
1398+ t . hovertemplate = 'Value: %{y}<br>Total percentage: %{percentTotal}<br>Initial percentage: %{percentInitial}<br>Previous percentage: %{percentPrevious }<extra></extra>' ;
13371399 } ) ;
13381400
13391401 function _hover ( ) {
@@ -1345,11 +1407,14 @@ describe('funnel hover', function() {
13451407 . then ( _hover )
13461408 . then ( function ( ) {
13471409 assertHoverLabelContent ( {
1348- nums : [ '1' , '2' , '1.5' ] ,
1410+ nums : [
1411+ 'Value: 1\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%' ,
1412+ 'Value: 2\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%' ,
1413+ 'Value: 1.5\nTotal percentage: 33.3%\nInitial percentage: 100%\nPrevious percentage: 100%'
1414+ ] ,
13491415 name : [ '' , '' , '' ] ,
13501416 axis : '0'
13511417 } ) ;
1352- // return Plotly.restyle(gd, 'text', ['APPLE', 'BANANA', 'ORANGE']);
13531418 } )
13541419 . catch ( failTest )
13551420 . then ( done ) ;
0 commit comments