@@ -29,6 +29,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
2929 yaListCartesian = [ ] ,
3030 xaListGl2d = [ ] ,
3131 yaListGl2d = [ ] ,
32+ xaListCheater = [ ] ,
33+ xaListNonCheater = [ ] ,
3234 outerTicks = { } ,
3335 noGrids = { } ,
3436 i ;
@@ -51,6 +53,21 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
5153 var xaName = axisIds . id2name ( trace . xaxis ) ,
5254 yaName = axisIds . id2name ( trace . yaxis ) ;
5355
56+ // Two things trigger axis visibility:
57+ // 1. is not carpet
58+ // 2. carpet that's not cheater
59+ if ( ! Registry . traceIs ( trace , 'carpet' ) || ( trace . type === 'carpet' && ! trace . _cheater ) ) {
60+ if ( xaName ) Lib . pushUnique ( xaListNonCheater , xaName ) ;
61+ }
62+
63+ // The above check for definitely-not-cheater is not adequate. This
64+ // second list tracks which axes *could* be a cheater so that the
65+ // full condition triggering hiding is:
66+ // *could* be a cheater and *is not definitely visible*
67+ if ( trace . type === 'carpet' && trace . _cheater ) {
68+ if ( xaName ) Lib . pushUnique ( xaListCheater , xaName ) ;
69+ }
70+
5471 // add axes implied by traces
5572 if ( xaName && listX . indexOf ( xaName ) === - 1 ) listX . push ( xaName ) ;
5673 if ( yaName && listY . indexOf ( yaName ) === - 1 ) listY . push ( yaName ) ;
@@ -168,7 +185,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
168185 showGrid : ! noGrids [ axName ] ,
169186 data : fullData ,
170187 bgColor : bgColor ,
171- calendar : layoutOut . calendar
188+ calendar : layoutOut . calendar ,
189+ cheateronly : axLetter === 'x' && ( xaListCheater . indexOf ( axName ) !== - 1 && xaListNonCheater . indexOf ( axName ) === - 1 )
172190 } ;
173191
174192 handleAxisDefaults ( axLayoutIn , axLayoutOut , coerce , defaultOptions , layoutOut ) ;
0 commit comments