antvis/G6

如何保持节点不动的情况下,让视图移动使节点处于视图中心位置 求帮助 #4625

ABCDdouyaer posted onGitHub

问题描述

<img width="821" alt="image" src="https://github.com/antvis/G6/assets/31639964/509dd6de-0250-4808-a8a5-b0f3460162c5">

这块我实在不知道如何转换坐标 不明白节点用的point位置还是啥,然后moveTo移动端到中心用的啥位置

重现链接

https://stackblitz.com/edit/typescript-9x1cf6?file=index.ts,index.html,style.less

重现步骤

描述中

预期行为

移动视图让节点处于中间

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • G6 版本: [4.5.1 ... ]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


聚焦到一个节点:graph.focusItem, 文档https://g6.antv.antgroup.com/api/graph-func/transform#graphfocusitemitem-animate-animatecfg

聚焦到多个节点形成的区域:graph.focusItems,第一个参数是 item 数组

posted by Yanyan-Wang almost 2 years ago

我的需求是点击一个节点的时候会以改节点为根改变所有视图数据 并且该根节点聚焦到视图中间并放大 目前改变数据存在force2的动画力 focusItem聚焦的位置并不对 我想着fx,fy定死该根节点 移动视图让该节点到中间 或者有其他办法 @Yanyan-Wang

posted by ABCDdouyaer almost 2 years ago

如果是数据变更,就数据变更完成后、布局完成后(graph.on('afterlayout', e => {}) 再调用 graph.focusItem 。如果 graph 配置了 animate: true,就在动画完成后做调用 graph.on('afteranimate', e => {})

posted by Yanyan-Wang almost 2 years 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