Skip to content

Commit 6429830

Browse files
committed
refactor addLabelData function - use w and h
1 parent 7cbb5ce commit 6429830

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/traces/contour/plot.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,20 @@ function locationCost(loc, textOpts, labelData, bounds) {
544544
}
545545

546546
exports.addLabelData = function(loc, textOpts, labelData, labelClipPathData) {
547-
var halfWidth = textOpts.width / 2 + LABEL_LINE_CLIP_PAD_X;
548-
var halfHeight = textOpts.height / 2;
547+
var w = textOpts.width + 2 * LABEL_LINE_CLIP_PAD_X;
548+
var h = textOpts.height;
549549

550550
var x = loc.x;
551551
var y = loc.y;
552552
var theta = loc.theta;
553553

554554
var sin = Math.sin(theta);
555555
var cos = Math.cos(theta);
556-
var dxw = halfWidth * cos;
557-
var dxh = halfHeight * sin;
558-
var dyw = halfWidth * sin;
559-
var dyh = -halfHeight * cos;
556+
var dxw = cos * w / 2;
557+
var dxh = sin * h / 2;
558+
var dyw = sin * w / 2;
559+
var dyh = -cos * h / 2;
560+
560561
var bBoxPts = [
561562
[x - dxw - dxh, y - dyw - dyh],
562563
[x + dxw - dxh, y + dyw - dyh],

0 commit comments

Comments
 (0)