@@ -112,20 +112,6 @@ function calculateGraph() {
112112 [node .x , node .y ] = [node .y ! - SPACING .width , node .x ! ]
113113 }
114114
115- // Offset the graph and adding margin
116- const minX = Math .min (... _importsNodes .map (n => n .x ! ))
117- const minY = Math .min (... _importsNodes .map (n => n .y ! ))
118- if (minX < SPACING .margin ) {
119- for (const node of _importsNodes ) {
120- node .x ! += Math .abs (minX ) + SPACING .margin
121- }
122- }
123- if (minY < SPACING .margin ) {
124- for (const node of _importsNodes ) {
125- node .y ! += Math .abs (minY ) + SPACING .margin
126- }
127- }
128-
129115 const _importsLinks = importsRoot .links ()
130116 .filter (x => x .source .data .module .id !== ' ~root' )
131117 .map ((x ): Link => {
@@ -191,6 +177,21 @@ function calculateGraph() {
191177 }
192178 })
193179
180+ // Offset the graph and adding margin
181+ const _nodes = [... _importsNodes , ... _importersNodes ]
182+ const minX = Math .min (... _nodes .map (n => n .x ! ))
183+ const minY = Math .min (... _nodes .map (n => n .y ! ))
184+ if (minX < SPACING .margin ) {
185+ for (const node of _nodes ) {
186+ node .x ! += Math .abs (minX ) + SPACING .margin
187+ }
188+ }
189+ if (minY < SPACING .margin ) {
190+ for (const node of _nodes ) {
191+ node .y ! += Math .abs (minY ) + SPACING .margin
192+ }
193+ }
194+
194195 const _importersLinks = importersRoot .links ()
195196 .filter (x => x .source .data .module .id !== ' ~root' )
196197 .map ((x ): Link => {
@@ -211,7 +212,7 @@ function calculateGraph() {
211212 })
212213
213214 // deduplicate modules
214- nodes .value = [ ... _importsNodes , ... _importersNodes ] .filter ((n , i , s ) =>
215+ nodes .value = _nodes .filter ((n , i , s ) =>
215216 i === s .findIndex (t => t .data .module .id === n .data .module .id ),
216217 )
217218 links .value = [... _importsLinks , ... _importersLinks ]
0 commit comments