@@ -1595,3 +1595,103 @@ describe('Test polar *gridshape linear* interactions', function() {
1595
1595
. then ( done ) ;
1596
1596
} ) ;
1597
1597
} ) ;
1598
+
1599
+
1600
+ describe ( 'Polar plots with css transforms' , function ( ) {
1601
+ var gd ;
1602
+
1603
+ beforeEach ( function ( ) {
1604
+ eventRecordings = { } ;
1605
+ gd = createGraphDiv ( ) ;
1606
+ } ) ;
1607
+
1608
+ afterEach ( destroyGraphDiv ) ;
1609
+
1610
+ function _getLocalPos ( element , point ) {
1611
+ var bb = element . getBoundingClientRect ( ) ;
1612
+ return [
1613
+ bb . left + point [ 0 ] ,
1614
+ bb . top + point [ 1 ]
1615
+ ] ;
1616
+ }
1617
+
1618
+ function transformPlot ( gd , transformString ) {
1619
+ gd . style . webkitTransform = transformString ;
1620
+ gd . style . MozTransform = transformString ;
1621
+ gd . style . msTransform = transformString ;
1622
+ gd . style . OTransform = transformString ;
1623
+ gd . style . transform = transformString ;
1624
+ }
1625
+
1626
+ function recalculateInverse ( gd ) {
1627
+ var inverse = Lib . inverseTransformMatrix ( Lib . getFullTransformMatrix ( gd ) ) ;
1628
+ gd . _fullLayout . _inverseTransform = inverse ;
1629
+ }
1630
+
1631
+ function _hover ( pos ) {
1632
+ return new Promise ( function ( resolve , reject ) {
1633
+ var localPos = _getLocalPos ( gd , pos ) ;
1634
+ gd . once ( 'plotly_hover' , function ( d ) {
1635
+ Lib . clearThrottle ( ) ;
1636
+ resolve ( d ) ;
1637
+ } ) ;
1638
+
1639
+ mouseEvent ( 'mousemove' , localPos [ 0 ] , localPos [ 1 ] ) ;
1640
+
1641
+ setTimeout ( function ( ) {
1642
+ reject ( 'plotly_hover did not get called!' ) ;
1643
+ } , 100 ) ;
1644
+ } ) ;
1645
+ }
1646
+
1647
+ var rVals = [ 100 , 50 , 50 , 100 ] ;
1648
+ var thetaVals = [ 135 , 135 , 315 , 315 ] ;
1649
+ var plotSize = [ 400 , 400 ] ;
1650
+ var mock = {
1651
+ data : [ {
1652
+ type : 'scatterpolar' ,
1653
+ r : rVals ,
1654
+ theta : thetaVals ,
1655
+ mode : 'markers' ,
1656
+ marker : {
1657
+ size : 20 ,
1658
+ }
1659
+ } ] ,
1660
+ layout : {
1661
+ width : plotSize [ 0 ] ,
1662
+ height : plotSize [ 1 ] ,
1663
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 } ,
1664
+ hovermode : 'closest'
1665
+ }
1666
+ } ;
1667
+ var transforms = [ 'scale(0.5)' ] ;
1668
+
1669
+ transforms . forEach ( function ( transform ) {
1670
+
1671
+ it ( `@transform_test @alex_test hover behaves correctly after css transform: ${ transform } ` , function ( done ) {
1672
+
1673
+ var hoverEvents = { } ;
1674
+
1675
+ Plotly . plot ( gd , Lib . extendDeep ( { } , mock ) )
1676
+ . then ( function ( ) {
1677
+ gd . on ( 'plotly_hover' , function ( d ) {
1678
+ hoverEvents [ d . points [ 0 ] . pointIndex ] = true ;
1679
+ } ) ;
1680
+ } )
1681
+ . then ( function ( ) {
1682
+ transformPlot ( gd , transform ) ;
1683
+ recalculateInverse ( gd ) ;
1684
+ } )
1685
+ . then ( function ( ) { _hover ( [ 32 , 32 ] ) ; } )
1686
+ . then ( function ( ) { _hover ( [ 65 , 65 ] ) ; } )
1687
+ . then ( function ( ) { _hover ( [ 132 , 132 ] ) ; } )
1688
+ . then ( function ( ) { _hover ( [ 165 , 165 ] ) ; } )
1689
+ . then ( function ( ) {
1690
+ expect ( Object . keys ( hoverEvents ) . length ) . toBe ( 4 ) ;
1691
+ } )
1692
+ . catch ( failTest )
1693
+ . then ( done ) ;
1694
+ } ) ;
1695
+ } ) ;
1696
+
1697
+ } ) ;
0 commit comments