@@ -60,11 +60,18 @@ primitives.famdiagram.FamilyBalance.prototype.balance = function (params) {
6060
6161 this . createOrgTree ( params , data ) ;
6262
63+ var currentLevelIndex , index = - 1 ;
6364 data . orgTree . loopLevels ( this , function ( treeItemId , treeItem , levelIndex ) {
64- result . treeLevels . addItem ( levelIndex , treeItemId , treeItem ) ;
65+ if ( params . logicalFamily . node ( treeItemId ) != null ) {
66+ if ( currentLevelIndex !== levelIndex ) {
67+ currentLevelIndex = levelIndex ;
68+ index += 1 ;
69+ }
70+ result . treeLevels . addItem ( index , treeItemId , treeItem ) ;
71+ }
6572 } ) ;
6673
67- this . recalcLevelsDepth ( result . bundles , result . connectorStacks , result . treeLevels , data . orgTree , data . orgPartners ) ;
74+ this . recalcLevelsDepth ( result . bundles , result . connectorStacks , result . treeLevels , params . logicalFamily ) ;
6875
6976 result . maximumId = data . maximumId ;
7077
@@ -853,9 +860,8 @@ primitives.famdiagram.FamilyBalance.prototype.createOrgItem = function (orgTree,
853860 return orgItem ;
854861} ;
855862
856- primitives . famdiagram . FamilyBalance . prototype . recalcLevelsDepth = function ( bundles , connectorStacks , treeLevels , orgTree , orgPartners ) {
857- var index , len ,
858- index2 , len2 ,
863+ primitives . famdiagram . FamilyBalance . prototype . recalcLevelsDepth = function ( bundles , connectorStacks , treeLevels , logicalFamily ) {
864+ var index2 , len2 ,
859865 index3 , len3 ,
860866 itemPosition ,
861867 bundle , bundlesToStack ,
@@ -871,29 +877,30 @@ primitives.famdiagram.FamilyBalance.prototype.recalcLevelsDepth = function (bund
871877
872878 treeLevels . loopLevelItems ( this , levelIndex , function ( itemid , treeItem , position ) {
873879 var fromItems = [ ] ,
874- toItems = [ ] ,
875- partners ;
880+ toItems = [ ] ;
876881 if ( ! processed . hasOwnProperty ( itemid ) ) {
877-
878-
879882 processed [ itemid ] = true ;
880- if ( ! treeItem . hideChildrenConnection ) {
883+ var familyItem = logicalFamily . node ( itemid ) ;
884+
885+ if ( ! familyItem . hideChildrenConnection ) {
881886 fromItems . push ( itemid ) ;
882887 }
883888
884- partners = orgPartners [ itemid ] ;
885- if ( partners != null ) {
886- for ( index = 0 , len = partners . length ; index < len ; index += 1 ) {
887- var partner = partners [ index ] ;
888- processed [ partner ] = true ;
889- fromItems . push ( partner ) ;
890- }
891- }
889+ logicalFamily . loopChildren ( this , itemid , function ( childid , child , index ) {
890+ logicalFamily . loopParents ( this , childid , function ( parentid , parentItem ) {
891+ if ( ! processed . hasOwnProperty ( parentid ) ) {
892+ processed [ parentid ] = true ;
893+ if ( ! parentItem . hideChildrenConnection ) {
894+ fromItems . push ( parentid ) ;
895+ }
896+ }
897+ return logicalFamily . SKIP ;
898+ } ) ;
892899
893- orgTree . loopChildren ( this , itemid , function ( childid , child , index ) {
894900 if ( ! child . hideParentConnection ) {
895901 toItems . push ( childid ) ;
896902 }
903+ return logicalFamily . SKIP ;
897904 } ) ; //ignore jslint
898905
899906 if ( fromItems . length > 1 || toItems . length > 0 ) {
0 commit comments