@@ -40,6 +40,12 @@ function mouseTo(x, y) {
4040 mouseEvent ( 'mouseover' , x , y ) ;
4141}
4242
43+ function mostOfDrag ( x1 , y1 , x2 , y2 ) {
44+ mouseTo ( x1 , y1 ) ;
45+ mouseEvent ( 'mousedown' , x1 , y1 ) ;
46+ mouseEvent ( 'mousemove' , x2 , y2 ) ;
47+ }
48+
4349function purgeGraphDiv ( done ) {
4450 var gd = d3 . select ( '.js-plotly-plot' ) . node ( ) ;
4551 if ( gd ) Plotly . purge ( gd ) ;
@@ -1301,7 +1307,7 @@ describe('parcoords react more attributes', function() {
13011307 } ) ;
13021308} ) ;
13031309
1304- describe ( 'parcoords constraint interactions' , function ( ) {
1310+ describe ( 'parcoords constraint interactions - without defined axis ranges ' , function ( ) {
13051311 var gd , initialDashArray0 , initialDashArray1 ;
13061312
13071313 function initialFigure ( ) {
@@ -1365,11 +1371,6 @@ describe('parcoords constraint interactions', function() {
13651371 return highlight . attributes [ 'stroke-dasharray' ] . value . split ( ',' ) . map ( Number ) ;
13661372 }
13671373
1368- function mostOfDrag ( x1 , y1 , x2 , y2 ) {
1369- mouseTo ( x1 , y1 ) ;
1370- mouseEvent ( 'mousedown' , x1 , y1 ) ;
1371- mouseEvent ( 'mousemove' , x2 , y2 ) ;
1372- }
13731374
13741375 function checkDashCount ( dashArray , intervals ) {
13751376 // no-selection dasharrays have 2 entries:
@@ -1539,3 +1540,88 @@ describe('parcoords constraint interactions', function() {
15391540 . then ( done ) ;
15401541 } ) ;
15411542} ) ;
1543+
1544+ describe ( 'parcoords constraint interactions - with defined axis ranges' , function ( ) {
1545+ function initialFigure ( ) {
1546+ return {
1547+ data : [ {
1548+ type : 'parcoords' ,
1549+ dimensions : [ {
1550+ values : [ 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ] ,
1551+
1552+ } , {
1553+ values : [ 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 , 6 , 6 , 7 , 7 , 8 , 8 , 9 , 9 ] ,
1554+ tickvals : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ,
1555+ ticktext : [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'i' , 'j' , 'k' , 'l' ] ,
1556+ range : [ 3 , 7 ] ,
1557+ constraintrange : [ 4 , 6 ]
1558+ } ]
1559+ } ] ,
1560+ layout : {
1561+ width : 400 ,
1562+ height : 400 ,
1563+ margin : { t : 100 , b : 100 , l : 100 , r : 100 }
1564+ }
1565+ } ;
1566+ }
1567+
1568+ var gd ;
1569+ var initialSnapDuration ;
1570+ var shortenedSnapDuration = 20 ;
1571+ var noSnapDelay = 20 ;
1572+ beforeAll ( function ( ) {
1573+ initialSnapDuration = PC . bar . snapDuration ;
1574+ PC . bar . snapDuration = shortenedSnapDuration ;
1575+ } ) ;
1576+
1577+ afterAll ( function ( ) {
1578+ purgeGraphDiv ( ) ;
1579+ PC . bar . snapDuration = initialSnapDuration ;
1580+ } ) ;
1581+
1582+ beforeEach ( function ( done ) {
1583+ var hasGD = ! ! gd ;
1584+ if ( ! hasGD ) gd = createGraphDiv ( ) ;
1585+
1586+ Plotly . react ( gd , initialFigure ( ) )
1587+ . catch ( failTest )
1588+ . then ( done ) ;
1589+ } ) ;
1590+
1591+ it ( '@noCI @gl updates constraints above and below axis ranges' , function ( done ) {
1592+ expect ( gd . data [ 0 ] . dimensions [ 1 ] . constraintrange ) . toBeCloseToArray ( [ 4 , 6 ] ) ;
1593+
1594+ var x = 295 ;
1595+
1596+ // first: move above range
1597+ mostOfDrag ( x , 200 , x , 100 ) ;
1598+ mouseEvent ( 'mouseup' , x , 100 ) ;
1599+ delay ( noSnapDelay ) ( )
1600+ . then ( function ( ) {
1601+ expect ( gd . data [ 0 ] . dimensions [ 1 ] . constraintrange ) . toBeCloseToArray ( [ 5.75 , 8.25 ] ) ;
1602+ // move back
1603+ mostOfDrag ( x , 110 , x , 210 ) ;
1604+ mouseEvent ( 'mouseup' , x , 210 ) ;
1605+ } )
1606+ . then ( delay ( noSnapDelay ) )
1607+ . then ( function ( ) {
1608+ expect ( gd . data [ 0 ] . dimensions [ 1 ] . constraintrange ) . toBeCloseToArray ( [ 3.75 , 6.25 ] ) ;
1609+ // move below range
1610+ mostOfDrag ( x , 200 , x , 300 ) ;
1611+ mouseEvent ( 'mouseup' , x , 300 ) ;
1612+ } )
1613+ . then ( delay ( noSnapDelay ) )
1614+ . then ( function ( ) {
1615+ expect ( gd . data [ 0 ] . dimensions [ 1 ] . constraintrange ) . toBeCloseToArray ( [ 1.75 , 4.25 ] ) ;
1616+ // move back
1617+ mostOfDrag ( x , 290 , x , 190 ) ;
1618+ mouseEvent ( 'mouseup' , x , 190 ) ;
1619+ } )
1620+ . then ( delay ( noSnapDelay ) )
1621+ . then ( function ( ) {
1622+ expect ( gd . data [ 0 ] . dimensions [ 1 ] . constraintrange ) . toBeCloseToArray ( [ 3.75 , 6.25 ] ) ;
1623+ } )
1624+ . catch ( failTest )
1625+ . then ( done ) ;
1626+ } ) ;
1627+ } ) ;
0 commit comments