@@ -31,11 +31,10 @@ function sankeyModel(layout, d, traceIndex) {
3131 var calcData = unwrap ( d ) ;
3232 var trace = calcData . trace ;
3333 var domain = trace . domain ;
34- var horizontal = trace . orientation === 'h' ||
35- trace . orientation === 'left-right' ||
36- trace . orientation === 'right-left' ;
37- var rightLeft = trace . orientation === 'right-left' ;
38- var bottomUp = trace . orientation === 'bottom-up' ;
34+ var horizontal = trace . orientation === 'h' ;
35+ // reverse flips the source side along the flow axis: horizontal -> sources on the
36+ // right (flow leftward), vertical -> sources at the bottom (flow upward).
37+ var reverse = trace . direction === 'reverse' ;
3938 var nodePad = trace . node . pad ;
4039 var nodeThickness = trace . node . thickness ;
4140 var nodeAlign = {
@@ -289,8 +288,7 @@ function sankeyModel(layout, d, traceIndex) {
289288 trace : trace ,
290289 guid : Lib . randstr ( ) ,
291290 horizontal : horizontal ,
292- rightLeft : rightLeft ,
293- bottomUp : bottomUp ,
291+ reverse : reverse ,
294292 width : width ,
295293 height : height ,
296294 nodePad : trace . node . pad ,
@@ -594,8 +592,7 @@ function nodeModel(d, n) {
594592 sizeAcross : d . width ,
595593 forceLayouts : d . forceLayouts ,
596594 horizontal : d . horizontal ,
597- rightLeft : d . rightLeft ,
598- bottomUp : d . bottomUp ,
595+ reverse : d . reverse ,
599596 darkBackground : Color . color ( n . color ) . isDark ( ) ,
600597 rgb : Color . rgb ( n . color ) ,
601598 alpha : Color . color ( n . color ) . alpha ( ) ,
@@ -638,19 +635,19 @@ function salientEnough(d) {return (d.link.width > 1 || d.linkLineWidth > 0);}
638635
639636function sankeyTransform ( d ) {
640637 if ( d . horizontal ) {
641- if ( d . rightLeft ) {
642- // right-left : sources on the right, flow leftward; horizontal mirror of left-right .
638+ if ( d . reverse ) {
639+ // horizontal + reverse : sources on the right, flow leftward; a mirror of forward .
643640 return strTranslate ( d . translateX + d . width , d . translateY ) + 'matrix(-1 0 0 1 0 0)' ;
644641 }
645- // h / left-right : sources on the left, flow rightward.
642+ // horizontal + forward : sources on the left, flow rightward.
646643 return strTranslate ( d . translateX , d . translateY ) + 'matrix(1 0 0 1 0 0)' ;
647644 }
648- if ( d . bottomUp ) {
649- // bottom-up : sources at the bottom, flow upward; a vertical mirror of top-down .
645+ if ( d . reverse ) {
646+ // vertical + reverse : sources at the bottom, flow upward; a mirror of forward .
650647 // Pure 90deg rotation (det +1) keeps the cross axis intact.
651648 return strTranslate ( d . translateX , d . translateY + d . height ) + 'matrix(0 -1 1 0 0 0)' ;
652649 }
653- // top-down (also 'v') : reflection about y=x, sources at the top, flow downward.
650+ // vertical + forward : reflection about y=x, sources at the top, flow downward.
654651 return strTranslate ( d . translateX , d . translateY ) + 'matrix(0 1 1 0 0 0)' ;
655652}
656653
@@ -1071,9 +1068,9 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
10711068 } )
10721069 . attr ( 'text-anchor' , function ( d ) {
10731070 // vertical: labels are centered over the node. horizontal: aligned to the outer
1074- // edge (right-left mirrors the layout, so the outer side and anchor flip).
1071+ // edge (reverse mirrors the layout, so the outer side and anchor flip).
10751072 if ( ! d . horizontal ) return 'middle' ;
1076- return ( d . left !== d . rightLeft ) ? 'end' : 'start' ;
1073+ return ( d . left !== d . reverse ) ? 'end' : 'start' ;
10771074 } )
10781075 . attr ( 'transform' , function ( d ) {
10791076 var e = d3 . select ( this ) ;
@@ -1088,9 +1085,9 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
10881085 if ( ! d . horizontal ) {
10891086 var posY = d . visibleHeight / 2 ;
10901087 // last Column (originalLayer === 1): put label towards center.
1091- var posX = d . bottomUp ?
1088+ var posX = d . reverse ?
10921089 ( d . left ? - ( pad + CAP_SHIFT * d . textFont . size ) : ( d . visibleWidth + pad ) ) : ( d . left ? - pad : ( d . visibleWidth + pad + CAP_SHIFT * d . textFont . size ) ) ;
1093- var flipV = d . bottomUp ? strRotate ( 90 ) : ( 'scale(-1,1)' + strRotate ( 90 ) ) ;
1090+ var flipV = d . reverse ? strRotate ( 90 ) : ( 'scale(-1,1)' + strRotate ( 90 ) ) ;
10941091 return strTranslate ( posX , posY ) + flipV ;
10951092 }
10961093
@@ -1102,10 +1099,10 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
11021099 } else {
11031100 posX += d . visibleWidth ;
11041101 }
1105- return strTranslate ( posX , posY ) + ( d . rightLeft ? 'scale(-1,1)' : '' ) ;
1102+ return strTranslate ( posX , posY ) + ( d . reverse ? 'scale(-1,1)' : '' ) ;
11061103 } ) ;
11071104
11081105 nodeLabel
11091106 . transition ( )
11101107 . ease ( c . ease ) . duration ( c . duration ) ;
1111- } ;
1108+ } ;
0 commit comments