@@ -115,8 +115,6 @@ function sankeyModel(layout, d, i) {
115115 node = sankeyNodes [ n ] ;
116116 node . width = width ;
117117 node . height = height ;
118- if ( node . parallel ) node . x = ( horizontal ? width : height ) * node . parallel ;
119- if ( node . perpendicular ) node . y = ( horizontal ? height : width ) * node . perpendicular ;
120118 }
121119
122120 switchToForceFormat ( nodes ) ;
@@ -180,9 +178,7 @@ function nodeModel(uniqueKeys, d, n) {
180178 zoneThicknessPad = c . nodePadAcross ,
181179 zoneLengthPad = d . nodePad / 2 ,
182180 visibleThickness = n . dx + 0.5 ,
183- visibleLength = n . dy - 0.5 ,
184- zoneThickness = visibleThickness + 2 * zoneThicknessPad ,
185- zoneLength = visibleLength + 2 * zoneLengthPad ;
181+ visibleLength = n . dy - 0.5 ;
186182
187183 var basicKey = n . label ;
188184 var foundKey = uniqueKeys [ basicKey ] ;
@@ -202,8 +198,8 @@ function nodeModel(uniqueKeys, d, n) {
202198 visibleHeight : Math . ceil ( visibleLength ) ,
203199 zoneX : - zoneThicknessPad ,
204200 zoneY : - zoneLengthPad ,
205- zoneWidth : zoneThickness ,
206- zoneHeight : zoneLength ,
201+ zoneWidth : visibleThickness + 2 * zoneThicknessPad ,
202+ zoneHeight : visibleLength + 2 * zoneLengthPad ,
207203 labelY : d . horizontal ? n . dy / 2 + 1 : n . dx / 2 + 1 ,
208204 left : n . originalLayer === 1 ,
209205 sizeAcross : d . width ,
@@ -257,33 +253,28 @@ function sizeNode(rect) {
257253 . attr ( 'height' , function ( d ) { return d . visibleHeight ; } ) ;
258254}
259255
260- function salientEnough ( d ) {
261- return d . link . dy > 1 || d . linkLineWidth > 0 ;
262- }
256+ function salientEnough ( d ) { return d . link . dy > 1 || d . linkLineWidth > 0 ; }
263257
264258function sankeyTransform ( d ) {
265259 var offset = 'translate(' + d . translateX + ',' + d . translateY + ')' ;
266260 return offset + ( d . horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)' ) ;
267261}
268262
269- function sankeyInverseTransform ( d ) {
270- return d . horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)' ;
271- }
272-
273263function nodeCentering ( d ) {
274264 return 'translate(' + ( d . horizontal ? 0 : d . labelY ) + ' ' + ( d . horizontal ? d . labelY : 0 ) + ')' ;
275265}
276266
277- function textFlip ( d ) {
278- return d . horizontal ? 'scale(1 1)' : 'scale(-1 1)' ;
279- }
280-
281267function textGuidePath ( d ) {
282268 return d3 . svg . line ( ) ( [
283269 [ d . horizontal ? ( d . left ? - d . sizeAcross : d . visibleWidth + c . nodeTextOffsetHorizontal ) : c . nodeTextOffsetHorizontal , 0 ] ,
284270 [ d . horizontal ? ( d . left ? - c . nodeTextOffsetHorizontal : d . sizeAcross ) : d . visibleHeight - c . nodeTextOffsetHorizontal , 0 ]
285271 ] ) ; }
286272
273+ function sankeyInverseTransform ( d ) { return d . horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)' ; }
274+ function textFlip ( d ) { return d . horizontal ? 'scale(1 1)' : 'scale(-1 1)' ; }
275+ function nodeTextColor ( d ) { return d . darkBackground && ! d . horizontal ? 'rgb(255,255,255)' : 'rgb(0,0,0)' ; }
276+ function nodeTextOffset ( d ) { return d . horizontal && d . left ? '100%' : '0%' ; }
277+
287278// event handling
288279
289280function attachPointerEvents ( selection , sankey , eventSet ) {
@@ -629,8 +620,8 @@ module.exports = function(svg, styledData, layout, callbacks) {
629620 . classed ( 'nodeLabelTextPath' , true )
630621 . attr ( 'alignment-baseline' , 'middle' )
631622 . attr ( 'xlink:href' , function ( d ) { return '#' + d . uniqueNodeLabelPathId ; } )
632- . attr ( 'startOffset' , function ( d ) { return d . horizontal && d . left ? '100%' : '0%' ; } )
633- . style ( 'fill' , function ( d ) { return d . darkBackground && ! d . horizontal ? 'rgb(255,255,255)' : 'rgb(0,0,0)' ; } ) ;
623+ . attr ( 'startOffset' , nodeTextOffset )
624+ . style ( 'fill' , nodeTextColor ) ;
634625
635626 nodeLabelTextPath
636627 . text ( function ( d ) { return d . horizontal || d . node . dy > 5 ? d . node . label : '' ; } )
@@ -639,6 +630,6 @@ module.exports = function(svg, styledData, layout, callbacks) {
639630 nodeLabelTextPath
640631 . transition ( )
641632 . ease ( c . ease ) . duration ( c . duration )
642- . attr ( 'startOffset' , function ( d ) { return d . horizontal && d . left ? '100%' : '0%' ; } )
643- . style ( 'fill' , function ( d ) { return d . darkBackground && ! d . horizontal ? 'rgb(255,255,255)' : 'rgb(0,0,0)' ; } ) ;
633+ . attr ( 'startOffset' , nodeTextOffset )
634+ . style ( 'fill' , nodeTextColor ) ;
644635} ;
0 commit comments