@@ -55,7 +55,6 @@ function lsInner(gd) {
5555 var gs = fullLayout . _size ;
5656 var pad = gs . p ;
5757 var axList = Axes . list ( gd , '' , true ) ;
58- var i , subplot , plotinfo , ax , xa , ya ;
5958
6059 fullLayout . _paperdiv . style ( {
6160 width : ( gd . _context . responsive && fullLayout . autosize && ! gd . _context . _hasZeroWidth && ! gd . layout . width ) ? '100%' : fullLayout . width + 'px' ,
@@ -74,43 +73,7 @@ function lsInner(gd) {
7473 if ( ! fullLayout . _has ( 'cartesian' ) ) {
7574 return Plots . previousPromises ( gd ) ;
7675 }
77-
78- function getLinePosition ( ax , counterAx , side ) {
79- var lwHalf = ax . _lw / 2 ;
80-
81- if ( ax . _id . charAt ( 0 ) === 'x' ) {
82- if ( ! counterAx ) return gs . t + gs . h * ( 1 - ( ax . position || 0 ) ) + ( lwHalf % 1 ) ;
83- else if ( side === 'top' ) return counterAx . _offset - pad - lwHalf ;
84- return counterAx . _offset + counterAx . _length + pad + lwHalf ;
85- }
86-
87- if ( ! counterAx ) return gs . l + gs . w * ( ax . position || 0 ) + ( lwHalf % 1 ) ;
88- else if ( side === 'right' ) return counterAx . _offset + counterAx . _length + pad + lwHalf ;
89- return counterAx . _offset - pad - lwHalf ;
90- }
91-
92- // some preparation of axis position info
93- for ( i = 0 ; i < axList . length ; i ++ ) {
94- ax = axList [ i ] ;
95-
96- var counterAx = ax . _anchorAxis ;
97-
98- // clear axis line positions, to be set in the subplot loop below
99- ax . _linepositions = { } ;
100-
101- // stash crispRounded linewidth so we don't need to pass gd all over the place
102- ax . _lw = Drawing . crispRound ( gd , ax . linewidth , 1 ) ;
103-
104- // figure out the main axis line and main mirror line position.
105- // it's easier to follow the logic if we handle these separately from
106- // ax._linepositions, which are only used by mirror=allticks
107- // for non-main-subplot ticks, and mirror=all(ticks)? for zero line
108- // hiding logic
109- ax . _mainLinePosition = getLinePosition ( ax , counterAx , ax . side ) ;
110- ax . _mainMirrorPosition = ( ax . mirror && counterAx ) ?
111- getLinePosition ( ax , counterAx ,
112- alignmentConstants . OPPOSITE_SIDE [ ax . side ] ) : null ;
113- }
76+ var i , subplot , plotinfo , xa , ya ;
11477
11578 // figure out which backgrounds we need to draw,
11679 // and in which layers to put them
@@ -253,9 +216,10 @@ function lsInner(gd) {
253216
254217 function mainPath ( ax , pathFn , pathFnFree ) {
255218 if ( ! ax . showline || subplot !== ax . _mainSubplot ) return '' ;
256- if ( ! ax . _anchorAxis ) return pathFnFree ( ax . _mainLinePosition ) ;
257- var out = pathFn ( ax . _mainLinePosition ) ;
258- if ( ax . mirror ) out += pathFn ( ax . _mainMirrorPosition ) ;
219+ var mainLinePosition = Axes . getAxisLinePosition ( gd , ax ) ;
220+ if ( ! ax . _anchorAxis ) return pathFnFree ( mainLinePosition ) ;
221+ var out = pathFn ( mainLinePosition ) ;
222+ if ( ax . mirror ) out += pathFn ( Axes . getAxisMirrorLinePosition ( gd , ax ) ) ;
259223 return out ;
260224 }
261225
@@ -280,30 +244,25 @@ function lsInner(gd) {
280244 */
281245 var xPath = 'M0,0' ;
282246 if ( shouldShowLinesOrTicks ( xa , subplot ) ) {
283- leftYLineWidth = findCounterAxisLineWidth ( xa , 'left' , ya , axList ) ;
247+ leftYLineWidth = findCounterAxisLineWidth ( gd , xa , 'left' , ya , axList ) ;
284248 xLinesXLeft = xa . _offset - ( leftYLineWidth ? ( pad + leftYLineWidth ) : 0 ) ;
285- rightYLineWidth = findCounterAxisLineWidth ( xa , 'right' , ya , axList ) ;
249+ rightYLineWidth = findCounterAxisLineWidth ( gd , xa , 'right' , ya , axList ) ;
286250 xLinesXRight = xa . _offset + xa . _length + ( rightYLineWidth ? ( pad + rightYLineWidth ) : 0 ) ;
287- xLinesYBottom = getLinePosition ( xa , ya , 'bottom' ) ;
288- xLinesYTop = getLinePosition ( xa , ya , 'top' ) ;
251+ xLinesYBottom = Axes . getAxisLinePosition ( gd , xa , ya , 'bottom' ) ;
252+ xLinesYTop = Axes . getAxisLinePosition ( gd , xa , ya , 'top' ) ;
289253
290254 // save axis line positions for extra ticks to reference
291255 // each subplot that gets ticks from "allticks" gets an entry:
292256 // [left or bottom, right or top]
293257 extraSubplot = ( ! xa . _anchorAxis || subplot !== xa . _mainSubplot ) ;
294- if ( extraSubplot && ( xa . mirror === 'allticks' || xa . mirror === 'all' ) ) {
295- xa . _linepositions [ subplot ] = [ xLinesYBottom , xLinesYTop ] ;
296- }
297-
298258 xPath = mainPath ( xa , xLinePath , xLinePathFree ) ;
299259 if ( extraSubplot && xa . showline && ( xa . mirror === 'all' || xa . mirror === 'allticks' ) ) {
300260 xPath += xLinePath ( xLinesYBottom ) + xLinePath ( xLinesYTop ) ;
301261 }
302262
303263 plotinfo . xlines
304- . style ( 'stroke-width' , xa . _lw + 'px' )
305- . call ( Color . stroke , xa . showline ?
306- xa . linecolor : 'rgba(0,0,0,0)' ) ;
264+ . style ( 'stroke-width' , crispRoundLineWidth ( gd , xa ) + 'px' )
265+ . call ( Color . stroke , xa . showline ? xa . linecolor : 'rgba(0,0,0,0)' ) ;
307266 }
308267 plotinfo . xlines . attr ( 'd' , xPath ) ;
309268
@@ -320,27 +279,22 @@ function lsInner(gd) {
320279 */
321280 var yPath = 'M0,0' ;
322281 if ( shouldShowLinesOrTicks ( ya , subplot ) ) {
323- connectYBottom = findCounterAxisLineWidth ( ya , 'bottom' , xa , axList ) ;
282+ connectYBottom = findCounterAxisLineWidth ( gd , ya , 'bottom' , xa , axList ) ;
324283 yLinesYBottom = ya . _offset + ya . _length + ( connectYBottom ? pad : 0 ) ;
325- connectYTop = findCounterAxisLineWidth ( ya , 'top' , xa , axList ) ;
284+ connectYTop = findCounterAxisLineWidth ( gd , ya , 'top' , xa , axList ) ;
326285 yLinesYTop = ya . _offset - ( connectYTop ? pad : 0 ) ;
327- yLinesXLeft = getLinePosition ( ya , xa , 'left' ) ;
328- yLinesXRight = getLinePosition ( ya , xa , 'right' ) ;
286+ yLinesXLeft = Axes . getAxisLinePosition ( gd , ya , xa , 'left' ) ;
287+ yLinesXRight = Axes . getAxisLinePosition ( gd , ya , xa , 'right' ) ;
329288
330289 extraSubplot = ( ! ya . _anchorAxis || subplot !== ya . _mainSubplot ) ;
331- if ( extraSubplot && ( ya . mirror === 'allticks' || ya . mirror === 'all' ) ) {
332- ya . _linepositions [ subplot ] = [ yLinesXLeft , yLinesXRight ] ;
333- }
334-
335290 yPath = mainPath ( ya , yLinePath , yLinePathFree ) ;
336291 if ( extraSubplot && ya . showline && ( ya . mirror === 'all' || ya . mirror === 'allticks' ) ) {
337292 yPath += yLinePath ( yLinesXLeft ) + yLinePath ( yLinesXRight ) ;
338293 }
339294
340295 plotinfo . ylines
341- . style ( 'stroke-width' , ya . _lw + 'px' )
342- . call ( Color . stroke , ya . showline ?
343- ya . linecolor : 'rgba(0,0,0,0)' ) ;
296+ . style ( 'stroke-width' , crispRoundLineWidth ( gd , ya ) + 'px' )
297+ . call ( Color . stroke , ya . showline ? ya . linecolor : 'rgba(0,0,0,0)' ) ;
344298 }
345299 plotinfo . ylines . attr ( 'd' , yPath ) ;
346300 }
@@ -360,9 +314,9 @@ function shouldShowLinesOrTicks(ax, subplot) {
360314 * It's assumed that counterAx is known to overlay the subplot we're working on
361315 * but it may not be its main axis.
362316 */
363- function shouldShowLineThisSide ( ax , side , counterAx ) {
317+ function shouldShowLineThisSide ( gd , ax , side , counterAx ) {
364318 // does counterAx get a line at all?
365- if ( ! counterAx . showline || ! counterAx . _lw ) return false ;
319+ if ( ! counterAx . showline || ! crispRoundLineWidth ( gd , ax ) ) return false ;
366320
367321 // are we drawing *all* lines for counterAx?
368322 if ( counterAx . mirror === 'all' || counterAx . mirror === 'allticks' ) return true ;
@@ -388,19 +342,23 @@ function shouldShowLineThisSide(ax, side, counterAx) {
388342 * then at all other potential counteraxes on or overlaying this subplot.
389343 * Take the line width from the first one that has a line.
390344 */
391- function findCounterAxisLineWidth ( ax , side , counterAx , axList ) {
392- if ( shouldShowLineThisSide ( ax , side , counterAx ) ) {
393- return counterAx . _lw ;
345+ function findCounterAxisLineWidth ( gd , ax , side , counterAx , axList ) {
346+ if ( shouldShowLineThisSide ( gd , ax , side , counterAx ) ) {
347+ return crispRoundLineWidth ( gd , counterAx ) ;
394348 }
395349 for ( var i = 0 ; i < axList . length ; i ++ ) {
396350 var axi = axList [ i ] ;
397- if ( axi . _mainAxis === counterAx . _mainAxis && shouldShowLineThisSide ( ax , side , axi ) ) {
398- return axi . _lw ;
351+ if ( axi . _mainAxis === counterAx . _mainAxis && shouldShowLineThisSide ( gd , ax , side , axi ) ) {
352+ return crispRoundLineWidth ( gd , axi ) ;
399353 }
400354 }
401355 return 0 ;
402356}
403357
358+ function crispRoundLineWidth ( gd , ax ) {
359+ return Drawing . crispRound ( gd , ax . linewidth , 1 ) ;
360+ }
361+
404362exports . drawMainTitle = function ( gd ) {
405363 var fullLayout = gd . _fullLayout ;
406364
0 commit comments