src/chart/treemap/treemapLayout.js
function position(row, rowFixedLength, rect, halfGapWidth, flush) {
    // When rowFixedLength === rect.width,
    // it is horizontal subdivision,
    // rowFixedLength is the width of the subdivision,
    // rowOtherLength is the height of the subdivision,
    // and nodes will be positioned from left to right.

    // wh[idx0WhenH] means: when horizontal,
    //      wh[idx0WhenH] => wh[0] => 'width'.
    //      xy[idx1WhenH] => xy[1] => 'y'.
    var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
    var idx1WhenH = 1 - idx0WhenH;
    var xy = ['x', 'y'];
    var wh = ['width', 'height'];

    var last = rect[xy[idx0WhenH]];
    var rowOtherLength = rowFixedLength
        ? row.area / rowFixedLength : 0;

    if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
        rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
    }
    for (var i = 0, rowLen = row.length; i < rowLen; i++) {
        var node = row[i];
        var nodeLayout = {};
        var step = rowOtherLength
            ? node.getLayout().area / rowOtherLength : 0;

        var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);

        // We use Math.max/min to avoid negative width/height when considering gap width.
        var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
        var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
        var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);

        nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
        nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);

        last += modWH;
        node.setLayout(nodeLayout, true);
    }

    rect[xy[idx1WhenH]] += rowOtherLength;
    rect[wh[idx1WhenH]] -= rowOtherLength;
}
function position(row, rowFixedLength, rect, halfGapWidth, flush) {
    // When rowFixedLength === rect.width,
    // it is horizontal subdivision,
    // rowFixedLength is the width of the subdivision,
    // rowOtherLength is the height of the subdivision,
    // and nodes will be positioned from left to right.

    // wh[idx0WhenH] means: when horizontal,
    //      wh[idx0WhenH] => wh[0] => 'width'.
    //      xy[idx1WhenH] => xy[1] => 'y'.
    var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
    var idx1WhenH = 1 - idx0WhenH;
    var xy = ['x', 'y'];
    var wh = ['width', 'height'];

    var last = rect[xy[idx0WhenH]];
    var rowOtherLength = rowFixedLength
        ? row.area / rowFixedLength : 0;

    if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
        rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
    }
    for (var i = 0, rowLen = row.length; i < rowLen; i++) {
        var node = row[i];
        var nodeLayout = {};
        var step = rowOtherLength
            ? node.getLayout().area / rowOtherLength : 0;

        var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);

        // We use Math.max/min to avoid negative width/height when considering gap width.
        var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
        var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
        var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);

        nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
        nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);

        last += modWH;
        node.setLayout(nodeLayout, true);
    }

    rect[xy[idx1WhenH]] += rowOtherLength;
    rect[wh[idx1WhenH]] -= rowOtherLength;
}
function position ( row , rowFixedLength , rect , halfGapWidth , flush ) { // When rowFixedLength === rect.width, // it is horizontal subdivision, // rowFixedLength is the width of the subdivision, // rowOtherLength is the height of the subdivision, // and nodes will be positioned from left to right. // wh[idx0WhenH] means: when horizontal, //      wh[idx0WhenH] => wh[0] => 'width'. //      xy[idx1WhenH] => xy[1] => 'y'. var idx0WhenH = rowFixedLength === rect . width ? 0 : 1 ; var idx1WhenH = 1 - idx0WhenH ; var xy = [ 'x' , 'y' ] ; var wh = [ 'width' , 'height' ] ; var last = rect [ xy [ idx0WhenH ] ] ; var rowOtherLength = rowFixedLength ? row . area / rowFixedLength : 0 ; if ( flush || rowOtherLength > rect [ wh [ idx1WhenH ] ] ) { rowOtherLength = rect [ wh [ idx1WhenH ] ] ; // over+underflow } for ( var i = 0 , rowLen = row . length ; i < rowLen ; i ++ ) { var node = row [ i ] ; var nodeLayout = { } ; var step = rowOtherLength ? node . getLayout ( ) . area / rowOtherLength : 0 ; var wh1 = nodeLayout [ wh [ idx1WhenH ] ] = mathMax ( rowOtherLength - 2 * halfGapWidth , 0 ) ; // We use Math.max/min to avoid negative width/height when considering gap width. var remain = rect [ xy [ idx0WhenH ] ] + rect [ wh [ idx0WhenH ] ] - last ; var modWH = ( i === rowLen - 1 || remain < step ) ? remain : step ; var wh0 = nodeLayout [ wh [ idx0WhenH ] ] = mathMax ( modWH - 2 * halfGapWidth , 0 ) ; nodeLayout [ xy [ idx1WhenH ] ] = rect [ xy [ idx1WhenH ] ] + mathMin ( halfGapWidth , wh1 / 2 ) ; nodeLayout [ xy [ idx0WhenH ] ] = last + mathMin ( halfGapWidth , wh0 / 2 ) ; last += modWH ; node . setLayout ( nodeLayout , true ) ; } rect [ xy [ idx1WhenH ] ] += rowOtherLength ; rect [ wh [ idx1WhenH ] ] -= rowOtherLength ; }
Positions the specified row of nodes. Modifies `rect`.
Positions the specified row of nodes . Modifies rect .