@@ -115,8 +115,6 @@ function sankeyModel(layout, d, i) {
115
115
node = sankeyNodes [ n ] ;
116
116
node . width = width ;
117
117
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 ;
120
118
}
121
119
122
120
switchToForceFormat ( nodes ) ;
@@ -180,9 +178,7 @@ function nodeModel(uniqueKeys, d, n) {
180
178
zoneThicknessPad = c . nodePadAcross ,
181
179
zoneLengthPad = d . nodePad / 2 ,
182
180
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 ;
186
182
187
183
var basicKey = n . label ;
188
184
var foundKey = uniqueKeys [ basicKey ] ;
@@ -202,8 +198,8 @@ function nodeModel(uniqueKeys, d, n) {
202
198
visibleHeight : Math . ceil ( visibleLength ) ,
203
199
zoneX : - zoneThicknessPad ,
204
200
zoneY : - zoneLengthPad ,
205
- zoneWidth : zoneThickness ,
206
- zoneHeight : zoneLength ,
201
+ zoneWidth : visibleThickness + 2 * zoneThicknessPad ,
202
+ zoneHeight : visibleLength + 2 * zoneLengthPad ,
207
203
labelY : d . horizontal ? n . dy / 2 + 1 : n . dx / 2 + 1 ,
208
204
left : n . originalLayer === 1 ,
209
205
sizeAcross : d . width ,
@@ -257,33 +253,28 @@ function sizeNode(rect) {
257
253
. attr ( 'height' , function ( d ) { return d . visibleHeight ; } ) ;
258
254
}
259
255
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 ; }
263
257
264
258
function sankeyTransform ( d ) {
265
259
var offset = 'translate(' + d . translateX + ',' + d . translateY + ')' ;
266
260
return offset + ( d . horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)' ) ;
267
261
}
268
262
269
- function sankeyInverseTransform ( d ) {
270
- return d . horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)' ;
271
- }
272
-
273
263
function nodeCentering ( d ) {
274
264
return 'translate(' + ( d . horizontal ? 0 : d . labelY ) + ' ' + ( d . horizontal ? d . labelY : 0 ) + ')' ;
275
265
}
276
266
277
- function textFlip ( d ) {
278
- return d . horizontal ? 'scale(1 1)' : 'scale(-1 1)' ;
279
- }
280
-
281
267
function textGuidePath ( d ) {
282
268
return d3 . svg . line ( ) ( [
283
269
[ d . horizontal ? ( d . left ? - d . sizeAcross : d . visibleWidth + c . nodeTextOffsetHorizontal ) : c . nodeTextOffsetHorizontal , 0 ] ,
284
270
[ d . horizontal ? ( d . left ? - c . nodeTextOffsetHorizontal : d . sizeAcross ) : d . visibleHeight - c . nodeTextOffsetHorizontal , 0 ]
285
271
] ) ; }
286
272
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
+
287
278
// event handling
288
279
289
280
function attachPointerEvents ( selection , sankey , eventSet ) {
@@ -629,8 +620,8 @@ module.exports = function(svg, styledData, layout, callbacks) {
629
620
. classed ( 'nodeLabelTextPath' , true )
630
621
. attr ( 'alignment-baseline' , 'middle' )
631
622
. 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 ) ;
634
625
635
626
nodeLabelTextPath
636
627
. text ( function ( d ) { return d . horizontal || d . node . dy > 5 ? d . node . label : '' ; } )
@@ -639,6 +630,6 @@ module.exports = function(svg, styledData, layout, callbacks) {
639
630
nodeLabelTextPath
640
631
. transition ( )
641
632
. 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 ) ;
644
635
} ;
0 commit comments