@@ -1733,6 +1733,65 @@ describe('Test axes', function() {
17331733 } ) ;
17341734 } ) ;
17351735
1736+ describe ( 'minallowed / maxallowed' , function ( ) {
1737+ // regression test for https://github.com/plotly/plotly.js/issues/7717
1738+ var gd ;
1739+
1740+ beforeEach ( function ( ) { gd = createGraphDiv ( ) ; } ) ;
1741+ afterEach ( destroyGraphDiv ) ;
1742+
1743+ function expectForward ( done , minallowed ) {
1744+ Plotly . newPlot ( gd , [ {
1745+ x : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ,
1746+ y : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1747+ } ] , {
1748+ xaxis : { minallowed : minallowed }
1749+ } ) . then ( function ( ) {
1750+ var r = gd . _fullLayout . xaxis . range ;
1751+ expect ( r [ 0 ] ) . toBeLessThan ( r [ 1 ] , 'axis should not be reversed for minallowed=' + minallowed ) ;
1752+ expect ( r [ 0 ] ) . toBe ( minallowed , 'axis min should be pinned at minallowed' ) ;
1753+ } ) . then ( done , done . fail ) ;
1754+ }
1755+
1756+ it ( 'does not reverse axis when minallowed exceeds default range max' , function ( done ) {
1757+ expectForward ( done , 7 ) ;
1758+ } ) ;
1759+
1760+ it ( 'does not reverse axis when minallowed equals default range max' , function ( done ) {
1761+ expectForward ( done , 6 ) ;
1762+ } ) ;
1763+
1764+ it ( 'does not reverse axis when minallowed is well above default range max' , function ( done ) {
1765+ expectForward ( done , 100 ) ;
1766+ } ) ;
1767+
1768+ it ( 'keeps explicit autorange:reversed even when minallowed is set' , function ( done ) {
1769+ Plotly . newPlot ( gd , [ {
1770+ x : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ,
1771+ y : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1772+ } ] , {
1773+ xaxis : { autorange : 'reversed' , minallowed : 7 }
1774+ } ) . then ( function ( ) {
1775+ var r = gd . _fullLayout . xaxis . range ;
1776+ expect ( r [ 0 ] ) . toBeGreaterThan ( r [ 1 ] , 'axis should remain reversed' ) ;
1777+ expect ( r [ 1 ] ) . toBe ( 7 , 'min slot (range[1] when reversed) should be minallowed' ) ;
1778+ } ) . then ( done , done . fail ) ;
1779+ } ) ;
1780+
1781+ it ( 'does not reverse axis when maxallowed is below default range min' , function ( done ) {
1782+ Plotly . newPlot ( gd , [ {
1783+ x : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ,
1784+ y : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1785+ } ] , {
1786+ xaxis : { maxallowed : - 2 }
1787+ } ) . then ( function ( ) {
1788+ var r = gd . _fullLayout . xaxis . range ;
1789+ expect ( r [ 0 ] ) . toBeLessThan ( r [ 1 ] , 'axis should not be reversed' ) ;
1790+ expect ( r [ 1 ] ) . toBe ( - 2 , 'axis max should be pinned at maxallowed' ) ;
1791+ } ) . then ( done , done . fail ) ;
1792+ } ) ;
1793+ } ) ;
1794+
17361795 describe ( 'constraints relayout' , function ( ) {
17371796 var gd ;
17381797
0 commit comments