antvis/G6

如何设置layout? #4673

neolee6053 posted onGitHub

问题描述

这是vis-network.可以看见周边的节点会跟着我拖拉的节点移动,而且大概围绕着它。 vis

但G6的周边的节点会离我拖拉的节点越来越远。 layout: { type: "force", preventOverlap: true, nodeSpacing: 1, linkDistance: 50,
nodeStrength: -150,
}, g6

这是100个节点的效果 Vis image G6 image

重现链接

https://codesandbox.io/s/g6-forked-46sws3?file=/index.js

重现步骤

如上

预期行为

如上

平台

  • 操作系统: [ Windows]
  • 网页浏览器: [Google Chrome,]
  • G6 版本: [4.8.15 ]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


换 force2 试试,改过的 demo:https://codesandbox.io/s/g6-forked-4d36sv

force 好像是因为默认配有向心力

posted by Yanyan-Wang almost 2 years ago

换 force2 试试,改过的 demo:https://codesandbox.io/s/g6-forked-4d36sv

force 好像是因为默认配有向心力

谢谢

  1. 我换了一换data.如何可以把同一个区域的节点更靠近一点呢?而不同区域的就远一点
  2. 而且如果我不调maxIteration 的话,它会不停的跳动
  3. 如果workerEnabled: true, 这里会erro graph.on("node:dragstart", (e) => { const forceLayout = graph.get("layoutController").layoutMethods[0]; forceLayout.stop(); });

https://codesandbox.io/s/g6-forked-wzlvp5?file=/index.js:21756-21767 image

posted by neolee6053 almost 2 years ago

G6的force是用d3的吗? 可能我想要达到的比较类似cola. https://marvl.infotech.monash.edu/webcola/#:~:text=js%20(A.K.A.,js%2C%20svg.

posted by neolee6053 almost 2 years ago

是的,force 是引用的 d3。force2 是 G6 实现的,我理解你是想要度数大的节点之间距离远一些,可以根据节点度数返回不同的 linkDistance https://g6.antv.antgroup.com/api/graph-layout/force2#layoutcfglinkdistance

posted by Yanyan-Wang almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests