@@ -16,6 +16,7 @@ var Plots = require('../../plots/plots');
1616var Lib = require ( '../../lib' ) ;
1717var Drawing = require ( '../drawing' ) ;
1818var Color = require ( '../color' ) ;
19+ var Titles = require ( '../titles' ) ;
1920
2021var Cartesian = require ( '../../plots/cartesian' ) ;
2122var Axes = require ( '../../plots/cartesian/axes' ) ;
@@ -97,11 +98,17 @@ module.exports = function(gd) {
9798
9899 // update range slider dimensions
99100
100- var margin = fullLayout . margin ,
101- graphSize = fullLayout . _size ,
102- domain = axisOpts . domain ,
103- oppDomain = oppAxisOpts . domain ,
104- tickHeight = ( axisOpts . _boundingBox || { } ) . height || 0 ;
101+ var margin = fullLayout . margin ;
102+ var graphSize = fullLayout . _size ;
103+ var domain = axisOpts . domain ;
104+ var tickHeight = ( axisOpts . _boundingBox || { } ) . height || 0 ;
105+
106+ var oppBottom = Infinity ;
107+ var subplotData = Axes . getSubplots ( gd , axisOpts ) ;
108+ for ( var i = 0 ; i < subplotData . length ; i ++ ) {
109+ var oppAxis = Axes . getFromId ( gd , subplotData [ i ] . substr ( subplotData [ i ] . indexOf ( 'y' ) ) ) ;
110+ oppBottom = Math . min ( oppBottom , oppAxis . domain [ 0 ] ) ;
111+ }
105112
106113 opts . _id = constants . name + axisOpts . _id ;
107114 opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
@@ -113,7 +120,7 @@ module.exports = function(gd) {
113120 var x = Math . round ( margin . l + ( graphSize . w * domain [ 0 ] ) ) ;
114121
115122 var y = Math . round (
116- margin . t + graphSize . h * ( 1 - oppDomain [ 0 ] ) +
123+ graphSize . t + graphSize . h * ( 1 - oppBottom ) +
117124 tickHeight +
118125 opts . _offsetShift + constants . extraPad
119126 ) ;
@@ -162,18 +169,31 @@ module.exports = function(gd) {
162169 // update current range
163170 setPixelRange ( rangeSlider , gd , axisOpts , opts , oppAxisOpts , oppAxisRangeOpts ) ;
164171
165- // update margins
172+ // title goes next to range slider instead of tick labels, so
173+ // just take it over and draw it from here
174+ if ( axisOpts . side === 'bottom' ) {
175+ Titles . draw ( gd , axisOpts . _id + 'title' , {
176+ propContainer : axisOpts ,
177+ propName : axisOpts . _name + '.title' ,
178+ placeholder : fullLayout . _dfltTitle . x ,
179+ attributes : {
180+ x : axisOpts . _offset + axisOpts . _length / 2 ,
181+ y : y + opts . _height + opts . _offsetShift + 10 + 1.5 * axisOpts . titlefont . size ,
182+ 'text-anchor' : 'middle'
183+ }
184+ } ) ;
185+ }
166186
187+ // update margins
167188 Plots . autoMargin ( gd , opts . _id , {
168189 x : domain [ 0 ] ,
169- y : oppDomain [ 0 ] ,
190+ y : oppBottom ,
170191 l : 0 ,
171192 r : 0 ,
172193 t : 0 ,
173194 b : opts . _height + margin . b + tickHeight ,
174195 pad : constants . extraPad + opts . _offsetShift * 2
175196 } ) ;
176-
177197 } ) ;
178198} ;
179199
0 commit comments