diff --git a/plugins/insight/client/index.vue b/plugins/insight/client/index.vue index 768b5e1b..6a898d4b 100644 --- a/plugins/insight/client/index.vue +++ b/plugins/insight/client/index.vue @@ -90,8 +90,26 @@ const svgAttrs = computed(() => { } }) -const forceLink = d3.forceLink(links.value).id(node => node.uid) -const forceManyBody = d3.forceManyBody().strength(-200) +function weight(link: Link) { + return link.type === 'solid' ? 1 : 0.2 +} + +function degree(node: Node) { + let count = 0 + for (const link of links.value) { + if (link.source !== node && link.target !== node) continue + count += weight(link) + } + return count +} + +const forceLink = d3.forceLink(links.value) + .id(node => node.uid) + .strength((link) => { + return weight(link) / Math.min(degree(link.source), degree(link.target)) + }) + +const forceManyBody = d3.forceManyBody() const forceX = d3.forceX() const forceY = d3.forceY() diff --git a/plugins/insight/client/link.vue b/plugins/insight/client/link.vue index 9d1ce9e6..3d64af99 100644 --- a/plugins/insight/client/link.vue +++ b/plugins/insight/client/link.vue @@ -12,8 +12,8 @@