Skip to content

Commit ace3525

Browse files
committed
simplify equations without yTopPx
1 parent 4ba402d commit ace3525

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/colorbar/draw.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function drawColorBar(g, opts, gd) {
251251
ax.tick0 = levelsIn.start;
252252
var dtick = levelsIn.size;
253253
// expand if too many contours, so we don't get too many ticks
254-
var autoNtick = Lib.constrain((vPx - (vPx - lenPx)) / 50, 4, 15) + 1;
254+
var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
255255
var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
256256
if(dtFactor > 1) {
257257
var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -511,11 +511,11 @@ function drawColorBar(g, opts, gd) {
511511
}
512512

513513
var outerwidth = 2 * xpad + innerWidth + borderwidth + outlinewidth / 2;
514-
var outerheight = vPx - (vPx - lenPx);
514+
var outerheight = lenPx;
515515

516516
g.select('.' + cn.cbbg).attr({
517517
x: uPx - xpad - (borderwidth + outlinewidth) / 2,
518-
y: (vPx - lenPx) - yExtraPx,
518+
y: vPx - lenPx - yExtraPx,
519519
width: Math.max(outerwidth, 2),
520520
height: Math.max(outerheight + 2 * yExtraPx, 2)
521521
})
@@ -525,7 +525,7 @@ function drawColorBar(g, opts, gd) {
525525

526526
g.selectAll('.' + cn.cboutline).attr({
527527
x: uPx,
528-
y: (vPx - lenPx) + ypad + (titleSide === 'top' ? titleHeight : 0),
528+
y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
529529
width: Math.max(thickPx, 2),
530530
height: Math.max(outerheight - 2 * ypad - titleHeight, 2)
531531
})

0 commit comments

Comments
 (0)