dist/js/jquery.orgchart.js
function ($nodeChart, data) {
      var newSiblingCount = $.isArray(data) ? data.length : data.children.length;
      var existingSibligCount = $nodeChart.parent().is('td') ? $nodeChart.closest('tr').children().length : 1;
      var siblingCount = existingSibligCount + newSiblingCount;
      var insertPostion = (siblingCount > 1) ? Math.floor(siblingCount/2 - 1) : 0;
      // just build the sibling nodes for the specific node
      if ($nodeChart.parent().is('td')) {
        var $parent = $nodeChart.closest('tr').prevAll('tr:last');
        $nodeChart.closest('tr').prevAll('tr:lt(2)').remove();
        this.buildChildNode($nodeChart.parent().closest('table'), data);
        var $siblingTds = $nodeChart.parent().closest('table').children('tr:last').children('td');
        if (existingSibligCount > 1) {
          this.complementLine($siblingTds.eq(0).before($nodeChart.closest('td').siblings().addBack().unwrap()), siblingCount, existingSibligCount);
        } else {
          this.complementLine($siblingTds.eq(insertPostion).after($nodeChart.closest('td').unwrap()), siblingCount, 1);
        }
      } else { // build the sibling nodes and parent node for the specific ndoe
        this.buildHierarchy($nodeChart.closest('.orgchart'), data);
        this.complementLine($nodeChart.next().children('tr:last').children().eq(insertPostion).after($('<td colspan="2">').append($nodeChart)),
          siblingCount, 1);
      }
    }
function ($nodeChart, data) {
      var newSiblingCount = $.isArray(data) ? data.length : data.children.length;
      var existingSibligCount = $nodeChart.parent().is('td') ? $nodeChart.closest('tr').children().length : 1;
      var siblingCount = existingSibligCount + newSiblingCount;
      var insertPostion = (siblingCount > 1) ? Math.floor(siblingCount/2 - 1) : 0;
      // just build the sibling nodes for the specific node
      if ($nodeChart.parent().is('td')) {
        var $parent = $nodeChart.closest('tr').prevAll('tr:last');
        $nodeChart.closest('tr').prevAll('tr:lt(2)').remove();
        this.buildChildNode($nodeChart.parent().closest('table'), data);
        var $siblingTds = $nodeChart.parent().closest('table').children('tr:last').children('td');
        if (existingSibligCount > 1) {
          this.complementLine($siblingTds.eq(0).before($nodeChart.closest('td').siblings().addBack().unwrap()), siblingCount, existingSibligCount);
        } else {
          this.complementLine($siblingTds.eq(insertPostion).after($nodeChart.closest('td').unwrap()), siblingCount, 1);
        }
      } else { // build the sibling nodes and parent node for the specific ndoe
        this.buildHierarchy($nodeChart.closest('.orgchart'), data);
        this.complementLine($nodeChart.next().children('tr:last').children().eq(insertPostion).after($('<td colspan="2">').append($nodeChart)),
          siblingCount, 1);
      }
    }
function ( $nodeChart , data ) { var newSiblingCount = $ . isArray ( data ) ? data . length : data . children . length ; var existingSibligCount = $nodeChart . parent ( ) . is ( 'td' ) ? $nodeChart . closest ( 'tr' ) . children ( ) . length : 1 ; var siblingCount = existingSibligCount + newSiblingCount ; var insertPostion = ( siblingCount > 1 ) ? Math . floor ( siblingCount / 2 - 1 ) : 0 ; // just build the sibling nodes for the specific node if ( $nodeChart . parent ( ) . is ( 'td' ) ) { var $parent = $nodeChart . closest ( 'tr' ) . prevAll ( 'tr:last' ) ; $nodeChart . closest ( 'tr' ) . prevAll ( 'tr:lt(2)' ) . remove ( ) ; this . buildChildNode ( $nodeChart . parent ( ) . closest ( 'table' ) , data ) ; var $siblingTds = $nodeChart . parent ( ) . closest ( 'table' ) . children ( 'tr:last' ) . children ( 'td' ) ; if ( existingSibligCount > 1 ) { this . complementLine ( $siblingTds . eq ( 0 ) . before ( $nodeChart . closest ( 'td' ) . siblings ( ) . addBack ( ) . unwrap ( ) ) , siblingCount , existingSibligCount ) ; } else { this . complementLine ( $siblingTds . eq ( insertPostion ) . after ( $nodeChart . closest ( 'td' ) . unwrap ( ) ) , siblingCount , 1 ) ; } } else { // build the sibling nodes and parent node for the specific ndoe this . buildHierarchy ( $nodeChart . closest ( '.orgchart' ) , data ) ; this . complementLine ( $nodeChart . next ( ) . children ( 'tr:last' ) . children ( ) . eq ( insertPostion ) . after ( $ ( '<td colspan="2">' ) . append ( $nodeChart ) ) , siblingCount , 1 ) ; } }
build the sibling nodes of specific node
build the sibling nodes of specific node