@@ -112,20 +112,6 @@ function calculateGraph() {
112
112
[node .x , node .y ] = [node .y ! - SPACING .width , node .x ! ]
113
113
}
114
114
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
-
129
115
const _importsLinks = importsRoot .links ()
130
116
.filter (x => x .source .data .module .id !== ' ~root' )
131
117
.map ((x ): Link => {
@@ -191,6 +177,21 @@ function calculateGraph() {
191
177
}
192
178
})
193
179
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
+
194
195
const _importersLinks = importersRoot .links ()
195
196
.filter (x => x .source .data .module .id !== ' ~root' )
196
197
.map ((x ): Link => {
@@ -211,7 +212,7 @@ function calculateGraph() {
211
212
})
212
213
213
214
// deduplicate modules
214
- nodes .value = [ ... _importsNodes , ... _importersNodes ] .filter ((n , i , s ) =>
215
+ nodes .value = _nodes .filter ((n , i , s ) =>
215
216
i === s .findIndex (t => t .data .module .id === n .data .module .id ),
216
217
)
217
218
links .value = [... _importsLinks , ... _importersLinks ]
0 commit comments