@@ -34,6 +34,7 @@ var BADNUM = constants.BADNUM;
3434
3535var MID_SHIFT = require ( '../../constants/alignment' ) . MID_SHIFT ;
3636var LINE_SPACING = require ( '../../constants/alignment' ) . LINE_SPACING ;
37+ var OPPOSITE_SIDE = require ( '../../constants/alignment' ) . OPPOSITE_SIDE ;
3738
3839var axes = module . exports = { } ;
3940
@@ -1863,11 +1864,13 @@ axes.drawOne = function(gd, ax, opts) {
18631864
18641865 seq . push ( function ( ) {
18651866 var s = ax . side . charAt ( 0 ) ;
1867+ var sMirror = OPPOSITE_SIDE [ ax . side ] . charAt ( 0 ) ;
18661868 var pos = axes . getPxPosition ( gd , ax ) ;
18671869 var outsideTickLen = ax . ticks === 'outside' ? ax . ticklen : 0 ;
18681870 var llbbox ;
18691871
18701872 var push ;
1873+ var mirrorPush ;
18711874 var rangeSliderPush ;
18721875
18731876 if ( ax . automargin || hasRangeSlider ) {
@@ -1935,13 +1938,27 @@ axes.drawOne = function(gd, ax, opts) {
19351938 if ( ax . title . text !== fullLayout . _dfltTitle [ axLetter ] ) {
19361939 push [ s ] += ax . title . font . size ;
19371940 }
1941+
1942+ if ( ax . mirror ) {
1943+ mirrorPush = { x : 0 , y : 0 , r : 0 , l : 0 , t : 0 , b : 0 } ;
1944+
1945+ mirrorPush [ sMirror ] = ax . linewidth ;
1946+ if ( ax . mirror && ax . mirror !== true ) mirrorPush [ sMirror ] += outsideTickLen ;
1947+
1948+ if ( ax . mirror === true || ax . mirror === 'ticks' ) {
1949+ mirrorPush [ counterLetter ] = ax . _anchorAxis . domain [ domainIndices [ 1 ] ] ;
1950+ } else if ( ax . mirror === 'all' || ax . mirror === 'allticks' ) {
1951+ mirrorPush [ counterLetter ] = [ ax . _counterDomainMin , ax . _counterDomainMax ] [ domainIndices [ 1 ] ] ;
1952+ }
1953+ }
19381954 }
19391955
19401956 if ( hasRangeSlider ) {
19411957 rangeSliderPush = Registry . getComponentMethod ( 'rangeslider' , 'autoMarginOpts' ) ( gd , ax ) ;
19421958 }
19431959
19441960 Plots . autoMargin ( gd , axAutoMarginID ( ax ) , push ) ;
1961+ Plots . autoMargin ( gd , axMirrorAutoMarginID ( ax ) , mirrorPush ) ;
19451962 Plots . autoMargin ( gd , rangeSliderAutoMarginID ( ax ) , rangeSliderPush ) ;
19461963 } ) ;
19471964
@@ -2843,6 +2860,9 @@ axes.allowAutoMargin = function(gd) {
28432860 var ax = axList [ i ] ;
28442861 if ( ax . automargin ) {
28452862 Plots . allowAutoMargin ( gd , axAutoMarginID ( ax ) ) ;
2863+ if ( ax . mirror ) {
2864+ Plots . allowAutoMargin ( gd , axMirrorAutoMarginID ( ax ) ) ;
2865+ }
28462866 }
28472867 if ( Registry . getComponentMethod ( 'rangeslider' , 'isVisible' ) ( ax ) ) {
28482868 Plots . allowAutoMargin ( gd , rangeSliderAutoMarginID ( ax ) ) ;
@@ -2851,6 +2871,7 @@ axes.allowAutoMargin = function(gd) {
28512871} ;
28522872
28532873function axAutoMarginID ( ax ) { return ax . _id + '.automargin' ; }
2874+ function axMirrorAutoMarginID ( ax ) { return axAutoMarginID ( ax ) + '.mirror' ; }
28542875function rangeSliderAutoMarginID ( ax ) { return ax . _id + '.rangeslider' ; }
28552876
28562877// swap all the presentation attributes of the axes showing these traces
0 commit comments