@@ -1672,9 +1672,7 @@ describe('Test multi-axis shapes', function() {
16721672 afterEach ( destroyGraphDiv ) ;
16731673
16741674 function getShape ( index ) {
1675- var s = d3SelectAll ( '.shapelayer path[data-index="' + index + '"]' ) ;
1676- expect ( s . size ( ) ) . toBe ( 1 ) ;
1677- return s ;
1675+ return d3SelectAll ( '.shapelayer path[data-index="' + index + '"]' ) ;
16781676 }
16791677
16801678 function getBoundingBox ( index ) {
@@ -1698,10 +1696,10 @@ describe('Test multi-axis shapes', function() {
16981696 { type : 'path' , xref : [ 'x' , 'x2' ] , yref : [ 'y' , 'y2' ] , path : 'M1,1L2,2' }
16991697 ]
17001698 } ) . then ( function ( ) {
1701- expect ( getShape ( 0 ) ) . not . toBe ( null ) ;
1702- expect ( getShape ( 1 ) ) . not . toBe ( null ) ;
1703- expect ( getShape ( 2 ) ) . not . toBe ( null ) ;
1704- expect ( getShape ( 3 ) ) . not . toBe ( null ) ;
1699+ expect ( getShape ( 0 ) . size ( ) ) . toBe ( 1 ) ;
1700+ expect ( getShape ( 1 ) . size ( ) ) . toBe ( 1 ) ;
1701+ expect ( getShape ( 2 ) . size ( ) ) . toBe ( 1 ) ;
1702+ expect ( getShape ( 3 ) . size ( ) ) . toBe ( 1 ) ;
17051703 } )
17061704 . then ( done , done . fail ) ;
17071705 } ) ;
@@ -1725,34 +1723,32 @@ describe('Test multi-axis shapes', function() {
17251723 } ) . then ( function ( ) {
17261724 var xa = gd . _fullLayout . xaxis ;
17271725 var xa2 = gd . _fullLayout . xaxis2 ;
1728-
1729- var lineExpectedLeft = xa . l2p ( 1 ) + xa . _offset ;
1730- var lineExpectedRight = xa2 . l2p ( 2 ) + xa2 . _offset ;
1731- var lineBBox = getBoundingBox ( 0 ) ;
1726+ var ya = gd . _fullLayout . yaxis ;
1727+ var ya2 = gd . _fullLayout . yaxis2 ;
17321728
1733- expect ( lineBBox . left ) . toBeCloseTo ( lineExpectedLeft ) ;
1734- expect ( lineBBox . right ) . toBeCloseTo ( lineExpectedRight ) ;
1729+ var lineBBox = getBoundingBox ( 0 ) ;
1730+ expect ( lineBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1731+ expect ( lineBBox . right ) . toBeCloseTo ( xa2 . l2p ( 2 ) + xa2 . _offset ) ;
1732+ expect ( lineBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1733+ expect ( lineBBox . top ) . toBeCloseTo ( ya2 . l2p ( 2 ) + ya2 . _offset ) ;
17351734
1736- var rectExpectedLeft = xa . l2p ( 1.5 ) + xa . _offset ;
1737- var rectExpectedRight = xa2 . l2p ( 1.5 ) + xa2 . _offset ;
17381735 var rectBBox = getBoundingBox ( 1 ) ;
1736+ expect ( rectBBox . left ) . toBeCloseTo ( xa . l2p ( 1.5 ) + xa . _offset ) ;
1737+ expect ( rectBBox . right ) . toBeCloseTo ( xa2 . l2p ( 1.5 ) + xa2 . _offset ) ;
1738+ expect ( rectBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1.5 ) + ya . _offset ) ;
1739+ expect ( rectBBox . top ) . toBeCloseTo ( ya2 . l2p ( 1.5 ) + ya2 . _offset ) ;
17391740
1740- expect ( rectBBox . left ) . toBeCloseTo ( rectExpectedLeft ) ;
1741- expect ( rectBBox . right ) . toBeCloseTo ( rectExpectedRight ) ;
1742-
1743- var circleExpectedLeft = xa . l2p ( 1 ) + xa . _offset ;
1744- var circleExpectedRight = xa2 . l2p ( 2 ) + xa2 . _offset ;
17451741 var circleBBox = getBoundingBox ( 2 ) ;
1742+ expect ( circleBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1743+ expect ( circleBBox . right ) . toBeCloseTo ( xa2 . l2p ( 2 ) + xa2 . _offset ) ;
1744+ expect ( circleBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1745+ expect ( circleBBox . top ) . toBeCloseTo ( ya2 . l2p ( 2 ) + ya2 . _offset ) ;
17461746
1747- expect ( circleBBox . left ) . toBeCloseTo ( circleExpectedLeft ) ;
1748- expect ( circleBBox . right ) . toBeCloseTo ( circleExpectedRight ) ;
1749-
1750- var pathExpectedLeft = xa . l2p ( 1 ) + xa . _offset ;
1751- var pathExpectedRight = xa2 . l2p ( 2 ) + xa2 . _offset ;
17521747 var pathBBox = getBoundingBox ( 3 ) ;
1753-
1754- expect ( pathBBox . left ) . toBeCloseTo ( pathExpectedLeft ) ;
1755- expect ( pathBBox . right ) . toBeCloseTo ( pathExpectedRight ) ;
1748+ expect ( pathBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1749+ expect ( pathBBox . right ) . toBeCloseTo ( xa2 . l2p ( 2 ) + xa2 . _offset ) ;
1750+ expect ( pathBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1751+ expect ( pathBBox . top ) . toBeCloseTo ( ya2 . l2p ( 2 ) + ya2 . _offset ) ;
17561752 } )
17571753 . then ( done , done . fail ) ;
17581754 } ) ;
@@ -1771,36 +1767,33 @@ describe('Test multi-axis shapes', function() {
17711767 { type : 'circle' , xref : 'x' , yref : [ 'y' , 'y2' ] , x0 : 1 , x1 : 2 , y0 : 1 , y1 : 65 } ,
17721768 { type : 'path' , xref : 'x' , yref : [ 'y' , 'y2' ] , path : 'M1,1L2,90' } ]
17731769 } ) . then ( function ( ) {
1770+ var xa = gd . _fullLayout . xaxis ;
17741771 var ya = gd . _fullLayout . yaxis ;
17751772 var ya2 = gd . _fullLayout . yaxis2 ;
17761773
1777- var lineExpectedBottom = ya . l2p ( 1 ) + ya . _offset ;
1778- var lineExpectedTop = ya2 . l2p ( 20 ) + ya2 . _offset ;
17791774 var lineBBox = getBoundingBox ( 0 ) ;
1775+ expect ( lineBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1776+ expect ( lineBBox . right ) . toBeCloseTo ( xa . l2p ( 2 ) + xa . _offset ) ;
1777+ expect ( lineBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1778+ expect ( lineBBox . top ) . toBeCloseTo ( ya2 . l2p ( 20 ) + ya2 . _offset ) ;
17801779
1781- expect ( lineBBox . bottom ) . toBeCloseTo ( lineExpectedBottom ) ;
1782- expect ( lineBBox . top ) . toBeCloseTo ( lineExpectedTop ) ;
1783-
1784- var rectExpectedBottom = ya . l2p ( 1.5 ) + ya . _offset ;
1785- var rectExpectedTop = ya2 . l2p ( 50 ) + ya2 . _offset ;
17861780 var rectBBox = getBoundingBox ( 1 ) ;
1781+ expect ( rectBBox . left ) . toBeCloseTo ( xa . l2p ( 1.5 ) + xa . _offset ) ;
1782+ expect ( rectBBox . right ) . toBeCloseTo ( xa . l2p ( 1.5 ) + xa . _offset ) ;
1783+ expect ( rectBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1.5 ) + ya . _offset ) ;
1784+ expect ( rectBBox . top ) . toBeCloseTo ( ya2 . l2p ( 50 ) + ya2 . _offset ) ;
17871785
1788- expect ( rectBBox . bottom ) . toBeCloseTo ( rectExpectedBottom ) ;
1789- expect ( rectBBox . top ) . toBeCloseTo ( rectExpectedTop ) ;
1790-
1791- var circleExpectedBottom = ya . l2p ( 1 ) + ya . _offset ;
1792- var circleExpectedTop = ya2 . l2p ( 65 ) + ya2 . _offset ;
17931786 var circleBBox = getBoundingBox ( 2 ) ;
1787+ expect ( circleBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1788+ expect ( circleBBox . right ) . toBeCloseTo ( xa . l2p ( 2 ) + xa . _offset ) ;
1789+ expect ( circleBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1790+ expect ( circleBBox . top ) . toBeCloseTo ( ya2 . l2p ( 65 ) + ya2 . _offset ) ;
17941791
1795- expect ( circleBBox . bottom ) . toBeCloseTo ( circleExpectedBottom ) ;
1796- expect ( circleBBox . top ) . toBeCloseTo ( circleExpectedTop ) ;
1797-
1798- var pathExpectedBottom = ya . l2p ( 1 ) + ya . _offset ;
1799- var pathExpectedTop = ya2 . l2p ( 90 ) + ya2 . _offset ;
18001792 var pathBBox = getBoundingBox ( 3 ) ;
1801-
1802- expect ( pathBBox . bottom ) . toBeCloseTo ( pathExpectedBottom ) ;
1803- expect ( pathBBox . top ) . toBeCloseTo ( pathExpectedTop ) ;
1793+ expect ( pathBBox . left ) . toBeCloseTo ( xa . l2p ( 1 ) + xa . _offset ) ;
1794+ expect ( pathBBox . right ) . toBeCloseTo ( xa . l2p ( 2 ) + xa . _offset ) ;
1795+ expect ( pathBBox . bottom ) . toBeCloseTo ( ya . l2p ( 1 ) + ya . _offset ) ;
1796+ expect ( pathBBox . top ) . toBeCloseTo ( ya2 . l2p ( 90 ) + ya2 . _offset ) ;
18041797 } )
18051798 . then ( done , done . fail ) ;
18061799 } ) ;
@@ -1858,7 +1851,7 @@ describe('Test multi-axis shapes', function() {
18581851 . then ( done , done . fail ) ;
18591852 } ) ;
18601853
1861- it ( 'updates shape when panning a referenced axis ' , function ( done ) {
1854+ it ( 'updates shape positions when axis range changes via relayout ' , function ( done ) {
18621855 Plotly . newPlot ( gd , [
18631856 { x : [ 0 , 4 ] , y : [ 0 , 4 ] } ,
18641857 { x : [ 0 , 4 ] , y : [ 0 , 4 ] , xaxis : 'x2' , yaxis : 'y2' }
@@ -1926,10 +1919,14 @@ describe('Test multi-axis shapes', function() {
19261919 x0 : 0 , x1 : 5 , y0 : 0 , y1 : 5
19271920 } ]
19281921 } ) . then ( function ( ) {
1929- expect ( gd . _fullLayout . xaxis . range [ 0 ] ) . toBeLessThan ( 1 ) ;
1930- expect ( gd . _fullLayout . yaxis . range [ 0 ] ) . toBeLessThan ( 1 ) ;
1931- expect ( gd . _fullLayout . xaxis2 . range [ 1 ] ) . toBeGreaterThan ( 4 ) ;
1932- expect ( gd . _fullLayout . yaxis2 . range [ 1 ] ) . toBeGreaterThan ( 4 ) ;
1922+ expect ( gd . _fullLayout . xaxis . range [ 0 ] ) . toBeLessThan ( 0 ) ;
1923+ expect ( gd . _fullLayout . xaxis . range [ 1 ] ) . toBeGreaterThan ( 2 ) ;
1924+ expect ( gd . _fullLayout . yaxis . range [ 0 ] ) . toBeLessThan ( 0 ) ;
1925+ expect ( gd . _fullLayout . yaxis . range [ 1 ] ) . toBeGreaterThan ( 2 ) ;
1926+ expect ( gd . _fullLayout . xaxis2 . range [ 0 ] ) . toBeLessThan ( 1 ) ;
1927+ expect ( gd . _fullLayout . xaxis2 . range [ 1 ] ) . toBeGreaterThan ( 5 ) ;
1928+ expect ( gd . _fullLayout . yaxis2 . range [ 0 ] ) . toBeLessThan ( 1 ) ;
1929+ expect ( gd . _fullLayout . yaxis2 . range [ 1 ] ) . toBeGreaterThan ( 5 ) ;
19331930 } )
19341931 . then ( done , done . fail ) ;
19351932 } ) ;
0 commit comments