@@ -1940,27 +1940,53 @@ axes.drawOne = function(gd, ax, opts) {
1940
1940
var hasRangeSlider = Registry . getComponentMethod ( 'rangeslider' , 'isVisible' ) ( ax ) ;
1941
1941
1942
1942
function doAutoMargins ( ) {
1943
- var push , rangeSliderPush ;
1943
+ var s = ax . side . charAt ( 0 ) ;
1944
+ var push ;
1945
+ var rangeSliderPush ;
1944
1946
1945
1947
if ( hasRangeSlider ) {
1946
1948
rangeSliderPush = Registry . getComponentMethod ( 'rangeslider' , 'autoMarginOpts' ) ( gd , ax ) ;
1947
1949
}
1948
1950
Plots . autoMargin ( gd , rangeSliderAutoMarginID ( ax ) , rangeSliderPush ) ;
1949
1951
1950
- var s = ax . side . charAt ( 0 ) ;
1951
1952
if ( ax . automargin && ( ! hasRangeSlider || s !== 'b' ) ) {
1952
1953
push = { x : 0 , y : 0 , r : 0 , l : 0 , t : 0 , b : 0 } ;
1953
1954
1954
- if ( axLetter === 'x' ) {
1955
- push . y = ( ax . anchor === 'free' ? ax . position :
1956
- ax . _anchorAxis . domain [ s === 't' ? 1 : 0 ] ) ;
1957
- push [ s ] += ax . _boundingBox . height ;
1958
- } else {
1959
- push . x = ( ax . anchor === 'free' ? ax . position :
1960
- ax . _anchorAxis . domain [ s === 'r' ? 1 : 0 ] ) ;
1961
- push [ s ] += ax . _boundingBox . width ;
1955
+ var bbox = ax . _boundingBox ;
1956
+ var counterAx = mainPlotinfo [ counterLetter + 'axis' ] ;
1957
+ var anchorAxDomainIndex ;
1958
+ var offset ;
1959
+
1960
+ switch ( axLetter + s ) {
1961
+ case 'xb' :
1962
+ anchorAxDomainIndex = 0 ;
1963
+ offset = bbox . top - counterAx . _length - counterAx . _offset ;
1964
+ push [ s ] = bbox . height ;
1965
+ break ;
1966
+ case 'xt' :
1967
+ anchorAxDomainIndex = 1 ;
1968
+ offset = counterAx . _offset - bbox . bottom ;
1969
+ push [ s ] = bbox . height ;
1970
+ break ;
1971
+ case 'yl' :
1972
+ anchorAxDomainIndex = 0 ;
1973
+ offset = counterAx . _offset - bbox . right ;
1974
+ push [ s ] = bbox . width ;
1975
+ break ;
1976
+ case 'yr' :
1977
+ anchorAxDomainIndex = 1 ;
1978
+ offset = bbox . left - counterAx . _length - counterAx . _offset ;
1979
+ push [ s ] = bbox . width ;
1980
+ break ;
1962
1981
}
1963
1982
1983
+ push [ counterLetter ] = ax . anchor === 'free' ?
1984
+ ax . position :
1985
+ ax . _anchorAxis . domain [ anchorAxDomainIndex ] ;
1986
+
1987
+ if ( push [ s ] > 0 ) {
1988
+ push [ s ] += offset ;
1989
+ }
1964
1990
if ( ax . title . text !== fullLayout . _dfltTitle [ axLetter ] ) {
1965
1991
push [ s ] += ax . title . font . size ;
1966
1992
}
0 commit comments