antvis/G6

force/force2 用作子图布局时,有时候并未真正执行布局算法(或者是执行了,没有刷新画布) #4725

SevenNorth posted onGitHub

Describe the bug

force/force2 用作子图布局

subLayoutData2: 新数据不涉及原有数据 subLayoutData2:新数据有一个边指向原有数据

force 布局

  1. 新增的子图的数据中, 某个边的从新节点指向图谱存在的节点时,子图布局没有执行, 新增节点在右上角, tick函数没有执行;该问题在demo中不稳定复现, 在项目实际使用时100%复现。建议强制刷新之后,先点击 “subLayoutData2” 按钮 image

  2. 新增的子图的数据中,不涉及原有节点,表现正常

force2 布局

  1. 新增的子图的数据中, 某个边的从新节点指向图谱存在的节点时,报错, 拖拽时有残影 image
  2. 新增的子图的数据中,不涉及原有节点,表现算是正常 image

Your Example Website or App

https://codesandbox.io/s/sublayloutbu-ju-wen-ti-5s85gx?file=/index.html

Steps to Reproduce the Bug or Issue

  1. 点击subLayoutData1
  2. 强制刷新页面
  3. 点击subLayoutData2
  4. 修改layoutType为 "force2"
  5. 点击subLayoutData1
  6. 点击subLayoutData2

Expected behavior

期望 force布局执行sublayout的时候,不论新增数据与原有的数据有无关联都能正常进行布局

Screenshots or Videos

No response

Platform

  • OS: [Windows]
  • Browser: [Chrome]
  • Version: [114.0.5735.199]

Additional context

No response


看了一下, 应该是你执行布局传的数据不完整

posted by GemT27 almost 2 years ago

试试 subLayout.init(graph.save());, 当然官方也有提供更换布局的API graph.updateLayout.

posted by GemT27 almost 2 years ago

拖拽时有残影可以试试 graph.get('canvas').set('localRefresh', false)

posted by GemT27 almost 2 years ago

晚点尝试一下

posted by SevenNorth almost 2 years ago

控制台有 warning 哈,subData 里面有一条边指向的 node4 不存在。去掉 node4 可以正常运行 image

如果你要指向原来数据里的一个节点,要把这个节点也放到布局里面去计算

posted by Yanyan-Wang almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests