antvis/G6

调用节点的hide方法后,再使用fitview,剩余节点没有居中 #4872

XiaoRIGE posted onGitHub

Describe the bug

点击dom,调用节点的hide方法,然后使用fitview,节点位置向右偏移

Your Example Website or App

www.test.com

Steps to Reproduce the Bug or Issue

1.调用hide 2.调用fitview 3.剩余节点没有居中

Expected behavior

期待调用fitview后剩余节点能够实现居中效果

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response


可以使用 graph.focusItems,参数参考 graph.focusItem 第一个参数改为数组

https://g6.antv.antgroup.com/api/graph-func/transform#graphfocusitemitem-animate-animatecfg

posted by Yanyan-Wang over 1 year ago

使用graph.focusItem能够达到居中效果,但是我们在页面其他地方比如ToolBar中也会调用fitview,我不能每个地方都换为foscsItems,然后传递当前画布没有隐藏的值啊。有更合适的解决方案吗?或者如何可以解决这个hide后不居中的问题?

posted by XiaoRIGE over 1 year ago

不是不可以,graph.getNodes().filter(node => node.isVisible()),传给 focusItems

posted by Yanyan-Wang over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests