@@ -1326,14 +1326,74 @@ describe('funnel hover', function() {
1326
1326
. then ( done ) ;
1327
1327
} ) ;
1328
1328
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
+
1329
1389
it ( 'should use hovertemplate if specified' , function ( done ) {
1330
1390
gd = createGraphDiv ( ) ;
1331
1391
1332
1392
var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_arrays' ) ) ;
1333
1393
mock . data . forEach ( function ( t ) {
1334
1394
t . type = 'funnel' ;
1335
1395
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>' ;
1337
1397
} ) ;
1338
1398
1339
1399
function _hover ( ) {
@@ -1345,11 +1405,14 @@ describe('funnel hover', function() {
1345
1405
. then ( _hover )
1346
1406
. then ( function ( ) {
1347
1407
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
+ ] ,
1349
1413
name : [ '' , '' , '' ] ,
1350
1414
axis : '0'
1351
1415
} ) ;
1352
- // return Plotly.restyle(gd, 'text', ['APPLE', 'BANANA', 'ORANGE']);
1353
1416
} )
1354
1417
. catch ( failTest )
1355
1418
. then ( done ) ;
0 commit comments