@@ -246,7 +246,9 @@ function sankeyModel(layout, d, traceIndex) {
246246 if ( trace . node . x . length && trace . node . y . length ) {
247247 for ( i = 0 ; i < Math . min ( trace . node . x . length , trace . node . y . length , graph . nodes . length ) ; i ++ ) {
248248 if ( trace . node . x [ i ] && trace . node . y [ i ] ) {
249- var pos = [ trace . node . x [ i ] * width , trace . node . y [ i ] * height ] ;
249+ var pos = horizontal
250+ ? [ trace . node . x [ i ] * width , trace . node . y [ i ] * height ]
251+ : [ trace . node . x [ i ] * height , trace . node . y [ i ] * width ] ;
250252 graph . nodes [ i ] . x0 = pos [ 0 ] - nodeThickness / 2 ;
251253 graph . nodes [ i ] . x1 = pos [ 0 ] + nodeThickness / 2 ;
252254
@@ -802,9 +804,13 @@ function persistFinalNodePositions(d, gd) {
802804 for ( var i = 0 ; i < d . graph . nodes . length ; i ++ ) {
803805 var nodeX = ( d . graph . nodes [ i ] . x0 + d . graph . nodes [ i ] . x1 ) / 2 ;
804806 var nodeY = ( d . graph . nodes [ i ] . y0 + d . graph . nodes [ i ] . y1 ) / 2 ;
805- x . push ( nodeX / d . figure . width ) ;
806- y . push ( nodeY / d . figure . height ) ;
807- }
807+ if ( d . trace . orientation === 'h' ) {
808+ x . push ( nodeX / d . figure . width ) ;
809+ y . push ( nodeY / d . figure . height ) ;
810+ } else {
811+ x . push ( nodeX / d . figure . height ) ;
812+ y . push ( nodeY / d . figure . width ) ;
813+ }
808814 Registry . call ( '_guiRestyle' , gd , {
809815 'node.x' : [ x ] ,
810816 'node.y' : [ y ]
0 commit comments