@@ -57,9 +57,9 @@ export default function sankeyLayout(ecModel: GlobalModel, api: ExtensionAPI) {
5757 const orient = seriesModel . get ( 'orient' ) ;
5858
5959 const nodeAlign = seriesModel . get ( 'nodeAlign' ) ;
60- const sortNodes = seriesModel . get ( 'sortNodes ' ) ;
60+ const sort = seriesModel . get ( 'sort ' ) ;
6161
62- layoutSankey ( nodes , edges , nodeWidth , nodeGap , width , height , iterations , orient , nodeAlign , sortNodes ) ;
62+ layoutSankey ( nodes , edges , nodeWidth , nodeGap , width , height , iterations , orient , nodeAlign , sort ) ;
6363 } ) ;
6464}
6565
@@ -73,10 +73,10 @@ function layoutSankey(
7373 iterations : number ,
7474 orient : LayoutOrient ,
7575 nodeAlign : SankeySeriesOption [ 'nodeAlign' ] ,
76- sortNodes : boolean
76+ sort : SankeySeriesOption [ 'sort' ]
7777) {
7878 computeNodeBreadths ( nodes , edges , nodeWidth , width , height , orient , nodeAlign ) ;
79- computeNodeDepths ( nodes , edges , height , width , nodeGap , iterations , orient , sortNodes ) ;
79+ computeNodeDepths ( nodes , edges , height , width , nodeGap , iterations , orient , sort ) ;
8080 computeEdgeDepths ( nodes , orient ) ;
8181}
8282
@@ -259,7 +259,7 @@ function scaleNodeBreadths(nodes: GraphNode[], kx: number, orient: LayoutOrient)
259259 * @param nodeGap the vertical distance between two nodes
260260 * in the same column.
261261 * @param iterations the number of iterations for the algorithm
262- * @param sortNodes whether to sort the nodes by y-position
262+ * @param sort sorting method used when resolving collisions within each column
263263 */
264264function computeNodeDepths (
265265 nodes : GraphNode [ ] ,
@@ -269,21 +269,21 @@ function computeNodeDepths(
269269 nodeGap : number ,
270270 iterations : number ,
271271 orient : LayoutOrient ,
272- sortNodes : boolean
272+ sort : SankeySeriesOption [ 'sort' ]
273273) {
274274 const nodesByBreadth = prepareNodesByBreadth ( nodes , orient ) ;
275275
276276 initializeNodeDepth ( nodesByBreadth , edges , height , width , nodeGap , orient ) ;
277- resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sortNodes ) ;
277+ resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sort ) ;
278278
279279 for ( let alpha = 1 ; iterations > 0 ; iterations -- ) {
280280 // 0.99 is a experience parameter, ensure that each iterations of
281281 // changes as small as possible.
282282 alpha *= 0.99 ;
283283 relaxRightToLeft ( nodesByBreadth , alpha , orient ) ;
284- resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sortNodes ) ;
284+ resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sort ) ;
285285 relaxLeftToRight ( nodesByBreadth , alpha , orient ) ;
286- resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sortNodes ) ;
286+ resolveCollisions ( nodesByBreadth , nodeGap , height , width , orient , sort ) ;
287287 }
288288}
289289
@@ -360,11 +360,11 @@ function resolveCollisions(
360360 height : number ,
361361 width : number ,
362362 orient : LayoutOrient ,
363- sortNodes : boolean
363+ sort : SankeySeriesOption [ 'sort' ]
364364) {
365365 const keyAttr = orient === 'vertical' ? 'x' : 'y' ;
366366 zrUtil . each ( nodesByBreadth , function ( nodes ) {
367- if ( sortNodes !== false ) {
367+ if ( sort !== null ) {
368368 nodes . sort ( function ( a , b ) {
369369 return a . getLayout ( ) [ keyAttr ] - b . getLayout ( ) [ keyAttr ] ;
370370 } ) ;
@@ -535,4 +535,4 @@ function computeEdgeDepths(nodes: GraphNode[], orient: LayoutOrient) {
535535 ty += edge . getLayout ( ) . dy ;
536536 } ) ;
537537 } ) ;
538- }
538+ }
0 commit comments