src/chart/sankey/sankeyLayout.js
function initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient) {
    var minKy = Infinity;
    zrUtil.each(nodesByBreadth, function (nodes) {
        var n = nodes.length;
        var sum = 0;
        zrUtil.each(nodes, function (node) {
            sum += node.getLayout().value;
        });
        var ky = orient === 'vertical'
                    ? (width - (n - 1) * nodeGap) / sum
                    : (height - (n - 1) * nodeGap) / sum;

        if (ky < minKy) {
            minKy = ky;
        }
    });

    zrUtil.each(nodesByBreadth, function (nodes) {
        zrUtil.each(nodes, function (node, i) {
            var nodeDy = node.getLayout().value * minKy;
            if (orient === 'vertical') {
                node.setLayout({x: i}, true);
                node.setLayout({dx: nodeDy}, true);
            }
            else {
                node.setLayout({y: i}, true);
                node.setLayout({dy: nodeDy}, true);
            }
        });
    });

    zrUtil.each(edges, function (edge) {
        var edgeDy = +edge.getValue() * minKy;
        edge.setLayout({dy: edgeDy}, true);
    });
}
function initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient) {
    var minKy = Infinity;
    zrUtil.each(nodesByBreadth, function (nodes) {
        var n = nodes.length;
        var sum = 0;
        zrUtil.each(nodes, function (node) {
            sum += node.getLayout().value;
        });
        var ky = orient === 'vertical'
                    ? (width - (n - 1) * nodeGap) / sum
                    : (height - (n - 1) * nodeGap) / sum;

        if (ky < minKy) {
            minKy = ky;
        }
    });

    zrUtil.each(nodesByBreadth, function (nodes) {
        zrUtil.each(nodes, function (node, i) {
            var nodeDy = node.getLayout().value * minKy;
            if (orient === 'vertical') {
                node.setLayout({x: i}, true);
                node.setLayout({dx: nodeDy}, true);
            }
            else {
                node.setLayout({y: i}, true);
                node.setLayout({dy: nodeDy}, true);
            }
        });
    });

    zrUtil.each(edges, function (edge) {
        var edgeDy = +edge.getValue() * minKy;
        edge.setLayout({dy: edgeDy}, true);
    });
}
function initializeNodeDepth ( nodesByBreadth , edges , height , width , nodeGap , orient ) { var minKy = Infinity ; zrUtil . each ( nodesByBreadth , function ( nodes ) { var n = nodes . length ; var sum = 0 ; zrUtil . each ( nodes , function ( node ) { sum += node . getLayout ( ) . value ; } ) ; var ky = orient === 'vertical' ? ( width - ( n - 1 ) * nodeGap ) / sum : ( height - ( n - 1 ) * nodeGap ) / sum ; if ( ky < minKy ) { minKy = ky ; } } ) ; zrUtil . each ( nodesByBreadth , function ( nodes ) { zrUtil . each ( nodes , function ( node , i ) { var nodeDy = node . getLayout ( ) . value * minKy ; if ( orient === 'vertical' ) { node . setLayout ( { x : i } , true ) ; node . setLayout ( { dx : nodeDy } , true ) ; } else { node . setLayout ( { y : i } , true ) ; node . setLayout ( { dy : nodeDy } , true ) ; } } ) ; } ) ; zrUtil . each ( edges , function ( edge ) { var edgeDy = + edge . getValue ( ) * minKy ; edge . setLayout ( { dy : edgeDy } , true ) ; } ) ; }
Compute the original y-position for each node

@param {module:echarts/data/Graph~Node} nodes  node of sankey view
@param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
group by the array of all sankey nodes based on the nodes x-position.
@param {module:echarts/data/Graph~Edge} edges  edge of sankey view
@param {number} height  the whole height of the area to draw the view
@param {number} nodeGap  the vertical distance between two nodes
Compute the original y - position for each node