@@ -172,12 +172,6 @@ exports.lsInner = function(gd) {
172172 . call ( Drawing . setTranslate , xa . _offset , ya . _offset )
173173 . call ( Drawing . setClipUrl , plotinfo . clipId ) ;
174174
175- function shouldShowLine ( ax , counterAx , side ) {
176- return ( ax . anchor === counterAx . _id && ( ax . mirror || ax . side === side ) ) ||
177- ax . mirror === 'all' || ax . mirror === 'allticks' ||
178- ( ax . mirrors && ax . mirrors [ counterAx . _id + side ] ) ;
179- }
180-
181175 var xIsFree = xa . anchor === 'free' ;
182176 var showFreeX = xIsFree && ! freeFinished [ xa . _id ] ;
183177 var showBottom = shouldShowLine ( xa , ya , 'bottom' ) ;
@@ -191,62 +185,6 @@ exports.lsInner = function(gd) {
191185 var xlw = Drawing . crispRound ( gd , xa . linewidth , 1 ) ;
192186 var ylw = Drawing . crispRound ( gd , ya . linewidth , 1 ) ;
193187
194- function findMainAxis ( ax ) {
195- return ax . overlaying ? Plotly . Axes . getFromId ( gd , ax . overlaying ) : ax ;
196- }
197-
198- function findCounterAxes ( ax ) {
199- var counterAxes = [ ] ;
200- var anchorAx = Plotly . Axes . getFromId ( gd , ax . anchor ) ;
201- if ( anchorAx ) {
202- var counterMain = findMainAxis ( anchorAx ) ;
203- if ( counterAxes . indexOf ( counterMain ) === - 1 ) {
204- counterAxes . push ( counterMain ) ;
205- }
206- for ( var i = 0 ; i < axList . length ; i ++ ) {
207- if ( axList [ i ] . overlaying === counterMain . _id &&
208- counterAxes . indexOf ( axList [ i ] ) === - 1
209- ) {
210- counterAxes . push ( axList [ i ] ) ;
211- }
212- }
213- }
214- return counterAxes ;
215- }
216-
217- function findLineWidth ( axes , side ) {
218- for ( var i = 0 ; i < axes . length ; i ++ ) {
219- var ax = axes [ i ] ;
220- if ( ax . anchor !== 'free' && shouldShowLine ( ax , { _id : ax . anchor } , side ) ) {
221- return Drawing . crispRound ( gd , ax . linewidth ) ;
222- }
223- }
224- }
225-
226- function findCounterAxisLineWidth ( ax , subplotCounterLineWidth ,
227- subplotCounterIsShown , side ) {
228- if ( subplotCounterIsShown ) return subplotCounterLineWidth ;
229-
230- var i ;
231-
232- // find all counteraxes for this one, then of these, find the
233- // first one that has a visible line on this side
234- var mainAxis = findMainAxis ( ax ) ;
235- var counterAxes = findCounterAxes ( mainAxis ) ;
236-
237- var lineWidth = findLineWidth ( counterAxes , side ) ;
238- if ( lineWidth ) return lineWidth ;
239-
240- for ( i = 0 ; i < axList . length ; i ++ ) {
241- if ( axList [ i ] . overlaying === mainAxis . _id ) {
242- counterAxes = findCounterAxes ( axList [ i ] ) ;
243- lineWidth = findLineWidth ( counterAxes , side ) ;
244- if ( lineWidth ) return lineWidth ;
245- }
246- }
247- return 0 ;
248- }
249-
250188 /*
251189 * x lines get longer where they meet y lines, to make a crisp corner
252190 * free x lines are not excluded - they don't necessarily *meet* the
@@ -261,8 +199,8 @@ exports.lsInner = function(gd) {
261199 * ------
262200 * ^ x2
263201 */
264- var xLinesXLeft = - pad - findCounterAxisLineWidth ( xa , ylw , showLeft , 'left' ) ;
265- var xLinesXRight = xa . _length + pad + findCounterAxisLineWidth ( xa , ylw , showRight , 'right' ) ;
202+ var xLinesXLeft = - pad - findCounterAxisLineWidth ( gd , xa , ylw , showLeft , 'left' , axList ) ;
203+ var xLinesXRight = xa . _length + pad + findCounterAxisLineWidth ( gd , xa , ylw , showRight , 'right' , axList ) ;
266204 var xLinesYFree = gs . h * ( 1 - ( xa . position || 0 ) ) + ( ( xlw / 2 ) % 1 ) ;
267205 var xLinesYBottom = ya . _length + pad + xlw / 2 ;
268206 var xLinesYTop = - pad - xlw / 2 ;
@@ -283,10 +221,10 @@ exports.lsInner = function(gd) {
283221 * seem worth adding a lot of complexity for.
284222 */
285223 var yLinesYBottom = ya . _length + pad + ( yIsFree ?
286- findCounterAxisLineWidth ( ya , xlw , showBottom , 'bottom' ) :
224+ findCounterAxisLineWidth ( gd , ya , xlw , showBottom , 'bottom' , axList ) :
287225 0 ) ;
288226 var yLinesYTop = - pad - ( yIsFree ?
289- findCounterAxisLineWidth ( ya , xlw , showTop , 'top' ) :
227+ findCounterAxisLineWidth ( gd , ya , xlw , showTop , 'top' , axList ) :
290228 0 ) ;
291229 var yLinesXFree = gs . w * ( ya . position || 0 ) + ( ( ylw / 2 ) % 1 ) ;
292230 var yLinesXLeft = - pad - ylw / 2 ;
@@ -390,6 +328,68 @@ exports.lsInner = function(gd) {
390328 return gd . _promises . length && Promise . all ( gd . _promises ) ;
391329} ;
392330
331+ function shouldShowLine ( ax , counterAx , side ) {
332+ return ( ax . anchor === counterAx . _id && ( ax . mirror || ax . side === side ) ) ||
333+ ax . mirror === 'all' || ax . mirror === 'allticks' ||
334+ ( ax . mirrors && ax . mirrors [ counterAx . _id + side ] ) ;
335+ }
336+
337+ function findMainAxis ( gd , ax ) {
338+ return ax . overlaying ? Plotly . Axes . getFromId ( gd , ax . overlaying ) : ax ;
339+ }
340+
341+ function findCounterAxes ( gd , ax , axList ) {
342+ var counterAxes = [ ] ;
343+ var anchorAx = Plotly . Axes . getFromId ( gd , ax . anchor ) ;
344+ if ( anchorAx ) {
345+ var counterMain = findMainAxis ( gd , anchorAx ) ;
346+ if ( counterAxes . indexOf ( counterMain ) === - 1 ) {
347+ counterAxes . push ( counterMain ) ;
348+ }
349+ for ( var i = 0 ; i < axList . length ; i ++ ) {
350+ if ( axList [ i ] . overlaying === counterMain . _id &&
351+ counterAxes . indexOf ( axList [ i ] ) === - 1
352+ ) {
353+ counterAxes . push ( axList [ i ] ) ;
354+ }
355+ }
356+ }
357+ return counterAxes ;
358+ }
359+
360+ function findLineWidth ( gd , axes , side ) {
361+ for ( var i = 0 ; i < axes . length ; i ++ ) {
362+ var ax = axes [ i ] ;
363+ if ( ax . anchor !== 'free' && shouldShowLine ( ax , { _id : ax . anchor } , side ) ) {
364+ return Drawing . crispRound ( gd , ax . linewidth ) ;
365+ }
366+ }
367+ }
368+
369+ function findCounterAxisLineWidth ( gd , ax , subplotCounterLineWidth ,
370+ subplotCounterIsShown , side , axList ) {
371+ if ( subplotCounterIsShown ) return subplotCounterLineWidth ;
372+
373+ var i ;
374+
375+ // find all counteraxes for this one, then of these, find the
376+ // first one that has a visible line on this side
377+ var mainAxis = findMainAxis ( gd , ax ) ;
378+ var counterAxes = findCounterAxes ( gd , mainAxis , axList ) ;
379+
380+ var lineWidth = findLineWidth ( gd , counterAxes , side ) ;
381+ if ( lineWidth ) return lineWidth ;
382+
383+ for ( i = 0 ; i < axList . length ; i ++ ) {
384+ if ( axList [ i ] . overlaying === mainAxis . _id ) {
385+ counterAxes = findCounterAxes ( gd , axList [ i ] , axList ) ;
386+ lineWidth = findLineWidth ( gd , counterAxes , side ) ;
387+ if ( lineWidth ) return lineWidth ;
388+ }
389+ }
390+ return 0 ;
391+ }
392+
393393exports . drawMainTitle = function ( gd ) {
394394 var fullLayout = gd . _fullLayout ;
395395
0 commit comments