Skip to content

Commit f5f4d62

Browse files
committed
refactor addLabelData function - add rotateXY function
1 parent 6429830 commit f5f4d62

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/traces/contour/plot.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,19 @@ exports.addLabelData = function(loc, textOpts, labelData, labelClipPathData) {
553553

554554
var sin = Math.sin(theta);
555555
var cos = Math.cos(theta);
556-
var dxw = cos * w / 2;
557-
var dxh = sin * h / 2;
558-
var dyw = sin * w / 2;
559-
var dyh = -cos * h / 2;
556+
557+
var rotateXY = function(dx, dy) {
558+
return [
559+
x + dx * cos - dy * sin,
560+
y + dx * sin + dy * cos
561+
];
562+
};
560563

561564
var bBoxPts = [
562-
[x - dxw - dxh, y - dyw - dyh],
563-
[x + dxw - dxh, y + dyw - dyh],
564-
[x + dxw + dxh, y + dyw + dyh],
565-
[x - dxw + dxh, y - dyw + dyh],
565+
rotateXY(-w / 2, -h / 2),
566+
rotateXY(-w / 2, h / 2),
567+
rotateXY(w / 2, h / 2),
568+
rotateXY(w / 2, -h / 2)
566569
];
567570

568571
labelData.push({

0 commit comments

Comments
 (0)