@@ -1428,24 +1428,310 @@ describe('Click events with hovermode color', function() {
1428
1428
} ) ;
1429
1429
} ) ;
1430
1430
1431
- // To Test
1432
- // -------
1433
-
1434
- // ### Hovering
1435
- // - Hover down to top middle category, and top path.
1436
- // - [ ] Path hover label
1437
- // - [ ] Category hover label for 'category', 'color', and 'dimension', `hovermode`
1438
- // - [ ] No category hover label for 'none', 'skip' `hovermode
1439
- // - [ ] Events emitted on path hover
1440
- // - [ ] Events emitted on category hover in 'category', 'color', 'dimension', and 'none' `hovermode`
1441
- // - [ ] No events emitted on category or path in 'skip' `hovermode`
1442
- // In each case, check hoverinfo text
1443
-
1444
- // ### Test that properties have the desired effect on models
1445
- // - [ ] visible
1446
- // - [ ] counts
1447
- // - [ ] bundlecolors
1448
- // - [ ] sortpaths
1449
- //
1450
- //
1451
- // ### Test Font styles ###
1431
+ describe ( 'Hover events' , function ( ) {
1432
+
1433
+ // Variable declarations
1434
+ // ---------------------
1435
+ // ### Trace level ###
1436
+ var gd ,
1437
+ mock ;
1438
+
1439
+ // Fixtures
1440
+ // --------
1441
+ beforeEach ( function ( ) {
1442
+ gd = createGraphDiv ( ) ;
1443
+ mock = Lib . extendDeep ( { } , require ( '@mocks/parcats_basic_freeform.json' ) ) ;
1444
+ } ) ;
1445
+
1446
+ afterEach ( destroyGraphDiv ) ;
1447
+
1448
+ it ( 'hover and unhover should fire on category' , function ( done ) {
1449
+
1450
+ var hoverData ,
1451
+ unhoverData ,
1452
+ mouseY0 ,
1453
+ mouseX0 ;
1454
+
1455
+ Plotly . newPlot ( gd , mock )
1456
+ . then ( function ( ) {
1457
+ /** @type {ParcatsViewModel } */
1458
+ var parcatsViewModel = d3 . select ( 'g.trace.parcats' ) . datum ( ) ;
1459
+
1460
+ gd . on ( 'plotly_hover' , function ( data ) {
1461
+ hoverData = data ;
1462
+ } ) ;
1463
+
1464
+ gd . on ( 'plotly_unhover' , function ( data ) {
1465
+ unhoverData = data ;
1466
+ } ) ;
1467
+
1468
+ // Hover over top category of middle dimension (category "A")
1469
+ var dimStartX = parcatsViewModel . dimensions [ 1 ] . x ;
1470
+
1471
+ mouseY0 = parcatsViewModel . y + parcatsViewModel . dimensions [ 1 ] . categories [ 2 ] . y + 10 ;
1472
+ mouseX0 = parcatsViewModel . x + dimStartX + dimWidth / 2 ;
1473
+
1474
+ // Position mouse for start of drag
1475
+ // --------------------------------
1476
+ mouseEvent ( 'mousemove' , mouseX0 , mouseY0 ) ;
1477
+ mouseEvent ( 'mouseover' , mouseX0 , mouseY0 ) ;
1478
+ Lib . clearThrottle ( ) ;
1479
+ } )
1480
+ . then ( delay ( CALLBACK_DELAY ) )
1481
+ . then ( function ( ) {
1482
+ // Check that hover callback was called
1483
+ expect ( hoverData ) . toBeDefined ( ) ;
1484
+
1485
+ // Check that the right points were reported
1486
+ var pts = hoverData . points . sort ( function ( a , b ) {
1487
+ return a . pointNumber - b . pointNumber ;
1488
+ } ) ;
1489
+ expect ( pts ) . toEqual ( [
1490
+ { curveNumber : 0 , pointNumber : 4 } ,
1491
+ { curveNumber : 0 , pointNumber : 5 } ,
1492
+ { curveNumber : 0 , pointNumber : 8 } ] ) ;
1493
+
1494
+ // Check that unhover is still undefined
1495
+ expect ( unhoverData ) . toBeUndefined ( ) ;
1496
+ } )
1497
+ . then ( function ( ) {
1498
+ // Unhover
1499
+ mouseEvent ( 'mouseout' , mouseX0 , mouseY0 ) ;
1500
+ Lib . clearThrottle ( ) ;
1501
+ } )
1502
+ . then ( function ( ) {
1503
+ // Check that unhover callback was called
1504
+ expect ( unhoverData ) . toBeDefined ( ) ;
1505
+
1506
+ // Check that the right points were reported
1507
+ var pts = unhoverData . points . sort ( function ( a , b ) {
1508
+ return a . pointNumber - b . pointNumber ;
1509
+ } ) ;
1510
+ expect ( pts ) . toEqual ( [
1511
+ { curveNumber : 0 , pointNumber : 4 } ,
1512
+ { curveNumber : 0 , pointNumber : 5 } ,
1513
+ { curveNumber : 0 , pointNumber : 8 } ] ) ;
1514
+ } )
1515
+ . catch ( failTest )
1516
+ . then ( done ) ;
1517
+ } ) ;
1518
+
1519
+ it ( 'hover and unhover should fire on path' , function ( done ) {
1520
+
1521
+ var hoverData ,
1522
+ unhoverData ,
1523
+ mouseY0 ,
1524
+ mouseX0 ;
1525
+
1526
+ Plotly . newPlot ( gd , mock )
1527
+ . then ( function ( ) {
1528
+ /** @type {ParcatsViewModel } */
1529
+ var parcatsViewModel = d3 . select ( 'g.trace.parcats' ) . datum ( ) ;
1530
+
1531
+ gd . on ( 'plotly_hover' , function ( data ) {
1532
+ hoverData = data ;
1533
+ } ) ;
1534
+
1535
+ gd . on ( 'plotly_unhover' , function ( data ) {
1536
+ unhoverData = data ;
1537
+ } ) ;
1538
+
1539
+
1540
+ var dimStartX = parcatsViewModel . dimensions [ 1 ] . x ;
1541
+ mouseY0 = parcatsViewModel . y + parcatsViewModel . dimensions [ 1 ] . categories [ 2 ] . y + 10 ;
1542
+ mouseX0 = parcatsViewModel . x + dimStartX + dimWidth + 10 ;
1543
+
1544
+ // Position mouse for start of drag
1545
+ // --------------------------------
1546
+ mouseEvent ( 'mousemove' , mouseX0 , mouseY0 ) ;
1547
+ mouseEvent ( 'mouseover' , mouseX0 , mouseY0 ) ;
1548
+ Lib . clearThrottle ( ) ;
1549
+ } )
1550
+ . then ( delay ( CALLBACK_DELAY ) )
1551
+ . then ( function ( ) {
1552
+ // Check that hover callback was called
1553
+ expect ( hoverData ) . toBeDefined ( ) ;
1554
+
1555
+ // Check that the right points were reported
1556
+ var pts = hoverData . points . sort ( function ( a , b ) {
1557
+ return a . pointNumber - b . pointNumber ;
1558
+ } ) ;
1559
+ expect ( pts ) . toEqual ( [
1560
+ { curveNumber : 0 , pointNumber : 5 } ,
1561
+ { curveNumber : 0 , pointNumber : 8 } ] ) ;
1562
+
1563
+ // Check that unhover is still undefined
1564
+ expect ( unhoverData ) . toBeUndefined ( ) ;
1565
+ } )
1566
+ . then ( function ( ) {
1567
+ // Unhover
1568
+ mouseEvent ( 'mouseout' , mouseX0 , mouseY0 ) ;
1569
+ Lib . clearThrottle ( ) ;
1570
+ } )
1571
+ . then ( function ( ) {
1572
+ // Check that unhover callback was called
1573
+ expect ( unhoverData ) . toBeDefined ( ) ;
1574
+
1575
+ // Check that the right points were reported
1576
+ var pts = unhoverData . points . sort ( function ( a , b ) {
1577
+ return a . pointNumber - b . pointNumber ;
1578
+ } ) ;
1579
+ expect ( pts ) . toEqual ( [
1580
+ { curveNumber : 0 , pointNumber : 5 } ,
1581
+ { curveNumber : 0 , pointNumber : 8 } ] ) ;
1582
+ } )
1583
+ . catch ( failTest )
1584
+ . then ( done ) ;
1585
+ } ) ;
1586
+ } ) ;
1587
+
1588
+ describe ( 'Hover events with hovermode color' , function ( ) {
1589
+
1590
+ // Variable declarations
1591
+ // ---------------------
1592
+ // ### Trace level ###
1593
+ var gd ,
1594
+ mock ;
1595
+
1596
+ // Fixtures
1597
+ // --------
1598
+ beforeEach ( function ( ) {
1599
+ gd = createGraphDiv ( ) ;
1600
+ mock = Lib . extendDeep ( { } , require ( '@mocks/parcats_hovermode_color.json' ) ) ;
1601
+ } ) ;
1602
+
1603
+ afterEach ( destroyGraphDiv ) ;
1604
+
1605
+ it ( 'hover and unhover should fire on category hovermode color' , function ( done ) {
1606
+
1607
+ var hoverData ,
1608
+ unhoverData ,
1609
+ mouseY0 ,
1610
+ mouseX0 ;
1611
+
1612
+ Plotly . newPlot ( gd , mock )
1613
+ . then ( function ( ) {
1614
+ /** @type {ParcatsViewModel } */
1615
+ var parcatsViewModel = d3 . select ( 'g.trace.parcats' ) . datum ( ) ;
1616
+
1617
+ gd . on ( 'plotly_hover' , function ( data ) {
1618
+ hoverData = data ;
1619
+ } ) ;
1620
+
1621
+ gd . on ( 'plotly_unhover' , function ( data ) {
1622
+ unhoverData = data ;
1623
+ } ) ;
1624
+
1625
+ // Hover over top category of middle dimension (category "A")
1626
+ var dimStartX = parcatsViewModel . dimensions [ 1 ] . x ;
1627
+
1628
+ mouseY0 = parcatsViewModel . y + parcatsViewModel . dimensions [ 1 ] . categories [ 2 ] . y + 10 ;
1629
+ mouseX0 = parcatsViewModel . x + dimStartX + dimWidth / 2 ;
1630
+
1631
+ // Position mouse for start of drag
1632
+ // --------------------------------
1633
+ mouseEvent ( 'mousemove' , mouseX0 , mouseY0 ) ;
1634
+ mouseEvent ( 'mouseover' , mouseX0 , mouseY0 ) ;
1635
+ Lib . clearThrottle ( ) ;
1636
+ } )
1637
+ . then ( delay ( CALLBACK_DELAY ) )
1638
+ . then ( function ( ) {
1639
+ // Check that hover callback was called
1640
+ expect ( hoverData ) . toBeDefined ( ) ;
1641
+
1642
+ // Check that the right points were reported
1643
+ var pts = hoverData . points . sort ( function ( a , b ) {
1644
+ return a . pointNumber - b . pointNumber ;
1645
+ } ) ;
1646
+ expect ( pts ) . toEqual ( [
1647
+ { curveNumber : 0 , pointNumber : 5 } ] ) ;
1648
+
1649
+ // Check that unhover is still undefined
1650
+ expect ( unhoverData ) . toBeUndefined ( ) ;
1651
+ } )
1652
+ . then ( function ( ) {
1653
+ // Unhover
1654
+ mouseEvent ( 'mouseout' , mouseX0 , mouseY0 ) ;
1655
+ Lib . clearThrottle ( ) ;
1656
+ } )
1657
+ . then ( function ( ) {
1658
+ // Check that unhover callback was called
1659
+ expect ( unhoverData ) . toBeDefined ( ) ;
1660
+
1661
+ // Check that the right points were reported
1662
+ var pts = unhoverData . points . sort ( function ( a , b ) {
1663
+ return a . pointNumber - b . pointNumber ;
1664
+ } ) ;
1665
+ expect ( pts ) . toEqual ( [
1666
+ { curveNumber : 0 , pointNumber : 5 } ] ) ;
1667
+ } )
1668
+ . catch ( failTest )
1669
+ . then ( done ) ;
1670
+ } ) ;
1671
+
1672
+ it ( 'hover and unhover should fire on path hovermode color' , function ( done ) {
1673
+
1674
+ var hoverData ,
1675
+ unhoverData ,
1676
+ mouseY0 ,
1677
+ mouseX0 ;
1678
+
1679
+ Plotly . newPlot ( gd , mock )
1680
+ . then ( function ( ) {
1681
+ /** @type {ParcatsViewModel } */
1682
+ var parcatsViewModel = d3 . select ( 'g.trace.parcats' ) . datum ( ) ;
1683
+
1684
+ gd . on ( 'plotly_hover' , function ( data ) {
1685
+ hoverData = data ;
1686
+ } ) ;
1687
+
1688
+ gd . on ( 'plotly_unhover' , function ( data ) {
1689
+ unhoverData = data ;
1690
+ } ) ;
1691
+
1692
+
1693
+ var dimStartX = parcatsViewModel . dimensions [ 1 ] . x ;
1694
+ mouseY0 = parcatsViewModel . y + parcatsViewModel . dimensions [ 1 ] . categories [ 2 ] . y + 10 ;
1695
+ mouseX0 = parcatsViewModel . x + dimStartX + dimWidth + 10 ;
1696
+
1697
+ // Position mouse for start of drag
1698
+ // --------------------------------
1699
+ mouseEvent ( 'mousemove' , mouseX0 , mouseY0 ) ;
1700
+ mouseEvent ( 'mouseover' , mouseX0 , mouseY0 ) ;
1701
+ Lib . clearThrottle ( ) ;
1702
+ } )
1703
+ . then ( delay ( CALLBACK_DELAY ) )
1704
+ . then ( function ( ) {
1705
+ // Check that hover callback was called
1706
+ expect ( hoverData ) . toBeDefined ( ) ;
1707
+
1708
+ // Check that the right points were reported
1709
+ var pts = hoverData . points . sort ( function ( a , b ) {
1710
+ return a . pointNumber - b . pointNumber ;
1711
+ } ) ;
1712
+ expect ( pts ) . toEqual ( [
1713
+ { curveNumber : 0 , pointNumber : 5 } ] ) ;
1714
+
1715
+ // Check that unhover is still undefined
1716
+ expect ( unhoverData ) . toBeUndefined ( ) ;
1717
+ } )
1718
+ . then ( function ( ) {
1719
+ // Unhover
1720
+ mouseEvent ( 'mouseout' , mouseX0 , mouseY0 ) ;
1721
+ Lib . clearThrottle ( ) ;
1722
+ } )
1723
+ . then ( function ( ) {
1724
+ // Check that unhover callback was called
1725
+ expect ( unhoverData ) . toBeDefined ( ) ;
1726
+
1727
+ // Check that the right points were reported
1728
+ var pts = unhoverData . points . sort ( function ( a , b ) {
1729
+ return a . pointNumber - b . pointNumber ;
1730
+ } ) ;
1731
+ expect ( pts ) . toEqual ( [
1732
+ { curveNumber : 0 , pointNumber : 5 } ] ) ;
1733
+ } )
1734
+ . catch ( failTest )
1735
+ . then ( done ) ;
1736
+ } ) ;
1737
+ } ) ;
0 commit comments