Skip to content

Commit 91e61da

Browse files
committed
refactor logic for horizontal and vertical sankey positioning
1 parent bbb3495 commit 91e61da

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/traces/sankey/render.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -990,23 +990,24 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
990990

991991
// TODO: handle MathJax
992992

993-
var posX;
994-
var posY;
993+
var posX = d.nodeLineWidth / 2 + TEXTPAD;
994+
var posY = ((d.horizontal ? d.visibleHeight : d.visibleWidth) - blockHeight) / 2;
995995
if(d.horizontal) {
996-
posX = d.left ? 0 : d.visibleWidth;
997-
posX += (d.left ? -1 : 1) * (d.nodeLineWidth / 2 + TEXTPAD);
998-
999-
posY = (d.visibleHeight - blockHeight) / 2;
1000-
} else {
1001-
posY = d.nodeLineWidth / 2 + TEXTPAD;
1002-
posX = (d.visibleWidth - blockHeight) / 2;
996+
if(d.left) {
997+
posX = -posX;
998+
} else {
999+
posX += d.visibleWidth;
1000+
}
10031001
}
10041002

10051003
var flipText = d.horizontal ? '' : (
10061004
'scale(-1,1)' + strRotate(90)
10071005
);
10081006

1009-
return strTranslate(posX, posY) + flipText;
1007+
return strTranslate(
1008+
d.horizontal ? posX : posY,
1009+
d.horizontal ? posY : posX
1010+
) + flipText;
10101011
});
10111012

10121013
nodeLabel

0 commit comments

Comments
 (0)