Skip to content

Commit 4ba402d

Browse files
committed
use (vPx - lenPx) in place of vTopPx
1 parent 073e6ef commit 4ba402d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/colorbar/draw.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ function drawColorBar(g, opts, gd) {
226226
// y positioning we can do correctly from the start
227227
var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
228228
var vPx = Math.round(gs.h * (1 - vFrac));
229-
var yTopPx = vPx - lenPx;
230229

231230
// stash a few things for makeEditable
232231
opts._lenFrac = lenFrac;
@@ -252,7 +251,7 @@ function drawColorBar(g, opts, gd) {
252251
ax.tick0 = levelsIn.start;
253252
var dtick = levelsIn.size;
254253
// 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;
256255
var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
257256
if(dtFactor > 1) {
258257
var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -512,11 +511,11 @@ function drawColorBar(g, opts, gd) {
512511
}
513512

514513
var outerwidth = 2 * xpad + innerWidth + borderwidth + outlinewidth / 2;
515-
var outerheight = vPx - yTopPx;
514+
var outerheight = vPx - (vPx - lenPx);
516515

517516
g.select('.' + cn.cbbg).attr({
518517
x: uPx - xpad - (borderwidth + outlinewidth) / 2,
519-
y: yTopPx - yExtraPx,
518+
y: (vPx - lenPx) - yExtraPx,
520519
width: Math.max(outerwidth, 2),
521520
height: Math.max(outerheight + 2 * yExtraPx, 2)
522521
})
@@ -526,7 +525,7 @@ function drawColorBar(g, opts, gd) {
526525

527526
g.selectAll('.' + cn.cboutline).attr({
528527
x: uPx,
529-
y: yTopPx + ypad + (titleSide === 'top' ? titleHeight : 0),
528+
y: (vPx - lenPx) + ypad + (titleSide === 'top' ? titleHeight : 0),
530529
width: Math.max(thickPx, 2),
531530
height: Math.max(outerheight - 2 * ypad - titleHeight, 2)
532531
})

0 commit comments

Comments
 (0)