hive/html/js/vjTreeSeries.js
// find height, totalDistance; find leafCoordinate for leaves
find height, totalDistance; find leafCoordinate for leaves
find height totalDistance ; find leafCoordinate for leaves
function pass1(node) {
            if (!node)
                return;
            this.numNodes++;
            if (this.showRoot <= node.depth) {
                if (!node.distance)
                    node.distance = 0;
                if (node.parent && this.showRoot <= node.parent.depth)
                    node.totalDistance = node.distance + node.parent.totalDistance;
                else
                    node.totalDistance = 0;
                if (node.totalDistance > this.maxTotalDistance)
                    this.maxTotalDistance = node.totalDistance;
                if (node.depth > this.maxDepth + this.showRoot)
                    this.maxDepth = node.depth - this.showRoot;
                if (node.distance && (this.minAbsDistance === undefined || this.minAbsDistance > Math.abs(node.distance))) {
                   this.minAbsDistance = Math.abs(node.distance);
                }
                if (!node.expanded || !node.children.length)
                    node.leafCoord = node.minLeafCoord = node.maxLeafCoord = this.numLeaves++;
            }
            if (node.expanded) {
                if (!allowNegativeDistance) {
                    var dsum = 0;
                    for (var i=0; i<node.children.length; i++) {
                        if (!node.children[i].distance)
                            node.children[i].distance = 0;
                        dsum += node.children[i].distance;
                    }
                    dsum = Math.max(dsum, 0);
                    var dcum = 0;
                    for (var i=0; i<node.children.length; i++) {
                        var d = node.children[i].distance;
                        var maxd = Math.max(0, Math.min(dsum, dsum - dcum));
                        if (d < 0) {
                            node.children[i].distance = 0;
                        } else if (d > maxd) {
                            node.children[i].distance = maxd;
                        }
                        dcum += d;
                    }
                }
                var mid = parseInt(node.children.length/2);
                for (var i=0; i<mid; i++)
                    pass1.call(this, node.children[i]);
                if (this.type == "rectangular" && this.rectangularLabelInline && node.expanded && node.children.length)
                    node.leafCoord = node.minLeafCoord = node.maxLeafCoord = this.numLeaves++;
                for (var i=mid; i<node.children.length; i++)
                    pass1.call(this, node.children[i]);
            }
        }
function pass1 ( node ) { if ( ! node ) return ; this . numNodes ++ ; if ( this . showRoot <= node . depth ) { if ( ! node . distance ) node . distance = 0 ; if ( node . parent && this . showRoot <= node . parent . depth ) node . totalDistance = node . distance + node . parent . totalDistance ; else node . totalDistance = 0 ; if ( node . totalDistance > this . maxTotalDistance ) this . maxTotalDistance = node . totalDistance ; if ( node . depth > this . maxDepth + this . showRoot ) this . maxDepth = node . depth - this . showRoot ; if ( node . distance && ( this . minAbsDistance === undefined || this . minAbsDistance > Math . abs ( node . distance ) ) ) { this . minAbsDistance = Math . abs ( node . distance ) ; } if ( ! node . expanded || ! node . children . length ) node . leafCoord = node . minLeafCoord = node . maxLeafCoord = this . numLeaves ++ ; } if ( node . expanded ) { if ( ! allowNegativeDistance ) { var dsum = 0 ; for ( var i = 0 ; i < node . children . length ; i ++ ) { if ( ! node . children [ i ] . distance ) node . children [ i ] . distance = 0 ; dsum += node . children [ i ] . distance ; } dsum = Math . max ( dsum , 0 ) ; var dcum = 0 ; for ( var i = 0 ; i < node . children . length ; i ++ ) { var d = node . children [ i ] . distance ; var maxd = Math . max ( 0 , Math . min ( dsum , dsum - dcum ) ) ; if ( d < 0 ) { node . children [ i ] . distance = 0 ; } else if ( d > maxd ) { node . children [ i ] . distance = maxd ; } dcum += d ; } } var mid = parseInt ( node . children . length / 2 ) ; for ( var i = 0 ; i < mid ; i ++ ) pass1 . call ( this , node . children [ i ] ) ; if ( this . type == "rectangular" && this . rectangularLabelInline && node . expanded && node . children . length ) node . leafCoord = node . minLeafCoord = node . maxLeafCoord = this . numLeaves ++ ; for ( var i = mid ; i < node . children . length ; i ++ ) pass1 . call ( this , node . children [ i ] ) ; } }
find height, totalDistance; find leafCoordinate for leaves
find height totalDistance ; find leafCoordinate for leaves
// rootlike nodes have a distance coordinate of 0 // clamp distances to non-negative value, while attempting to preserve their sum