@@ -226,7 +226,6 @@ function drawColorBar(g, opts, gd) {
226
226
// y positioning we can do correctly from the start
227
227
var vFrac = optsY + lenFrac * ( ( { top : - 0.5 , bottom : 0.5 } [ yanchor ] || 0 ) - 0.5 ) ;
228
228
var vPx = Math . round ( gs . h * ( 1 - vFrac ) ) ;
229
- var yTopPx = vPx - lenPx ;
230
229
231
230
// stash a few things for makeEditable
232
231
opts . _lenFrac = lenFrac ;
@@ -252,7 +251,7 @@ function drawColorBar(g, opts, gd) {
252
251
ax . tick0 = levelsIn . start ;
253
252
var dtick = levelsIn . size ;
254
253
// expand if too many contours, so we don't get too many ticks
255
- var autoNtick = Lib . constrain ( ( vPx - yTopPx ) / 50 , 4 , 15 ) + 1 ;
254
+ var autoNtick = Lib . constrain ( ( vPx - ( vPx - lenPx ) ) / 50 , 4 , 15 ) + 1 ;
256
255
var dtFactor = ( zrange [ 1 ] - zrange [ 0 ] ) / ( ( opts . nticks || autoNtick ) * dtick ) ;
257
256
if ( dtFactor > 1 ) {
258
257
var dtexp = Math . pow ( 10 , Math . floor ( Math . log ( dtFactor ) / Math . LN10 ) ) ;
@@ -512,11 +511,11 @@ function drawColorBar(g, opts, gd) {
512
511
}
513
512
514
513
var outerwidth = 2 * xpad + innerWidth + borderwidth + outlinewidth / 2 ;
515
- var outerheight = vPx - yTopPx ;
514
+ var outerheight = vPx - ( vPx - lenPx ) ;
516
515
517
516
g . select ( '.' + cn . cbbg ) . attr ( {
518
517
x : uPx - xpad - ( borderwidth + outlinewidth ) / 2 ,
519
- y : yTopPx - yExtraPx ,
518
+ y : ( vPx - lenPx ) - yExtraPx ,
520
519
width : Math . max ( outerwidth , 2 ) ,
521
520
height : Math . max ( outerheight + 2 * yExtraPx , 2 )
522
521
} )
@@ -526,7 +525,7 @@ function drawColorBar(g, opts, gd) {
526
525
527
526
g . selectAll ( '.' + cn . cboutline ) . attr ( {
528
527
x : uPx ,
529
- y : yTopPx + ypad + ( titleSide === 'top' ? titleHeight : 0 ) ,
528
+ y : ( vPx - lenPx ) + ypad + ( titleSide === 'top' ? titleHeight : 0 ) ,
530
529
width : Math . max ( thickPx , 2 ) ,
531
530
height : Math . max ( outerheight - 2 * ypad - titleHeight , 2 )
532
531
} )
0 commit comments