G6 icon indicating copy to clipboard operation
G6 copied to clipboard

官方示例配置下,G6.TreeGraph树图的初始位置不正常

Open HiWayne opened this issue 3 years ago • 3 comments

Describe the bug

G6.TreeGraph实例的初始位置不正常,十分偏上,只有少量底部能在canvas中出现,于是不得不使用treeGraph.moveTo修正。

自己的可在线运行demo官方示例中的/pages/tree/index.js均能复现。另外如果这只是feature的话,为什么不默认在(0, 0)或(50%, 50%) ?

@antv/g6 复现版本:

  1. 自己:v4.5.2
  2. 官方:v3.8.5

node版本:

  1. 自己:v12.22.6
  2. 官方:v12.18.0

react版本:

  1. 自己:v17.0.2
  2. 官方:v16.14.0

Your Example Website or App

https://replit.com/@HiWayne/antv-in-react#src/App.jsx

Steps to Reproduce the Bug or Issue

  1. 打开或刷新页面
  2. 可以看到tree的初始位置停留不正常,仅有少部分出现在canvas区域中

Expected behavior

符合心智模型的效果应该如图: image

实际自己的可在线运行demo运行效果如图(可能因为版本从3 -> 4,所以相同配置下节点由方形变成圆形,这点可以忽略): image

实际官方示例运行效果如图: image

Screenshots or Videos

No response

Platform

  • OS: macOS Catalina 10.15.7
  • Browser: Chrome
  • Browser Version: 96.0.4664.110(正式版本) (x86_64)

Additional context

No response

HiWayne avatar Jan 14 '22 08:01 HiWayne

链接不是官网示例哈

render 之后调用 graph.fitView() ,参考官网 demo https://g6.antv.vision/zh/examples/tree/compactBox#basicCompactBox

Yanyan-Wang avatar Jan 29 '22 04:01 Yanyan-Wang

链接不是官网示例哈

render 之后调用 graph.fitView() ,参考官网 demo https://g6.antv.vision/zh/examples/tree/compactBox#basicCompactBox

这个应该是官方文档吧:https://antv-g6.gitee.io/zh/docs/manual/getting-started#react-%E4%B8%AD%E4%BD%BF%E7%94%A8-g6

image

点击Demo就是上述那个『官方示例』github仓库

HiWayne avatar Feb 01 '22 10:02 HiWayne

@Yanyan-Wang 我从4.5.5版本升级到4.6.x版本后,发现 GraphOptions.fitViewGraphOptions.fitCenter 设置为 true,都无效了。

是只能手动调用 graph.fitView() 才可以吗?

gotounix avatar May 10 '22 08:05 gotounix

升级到最新版本试试,我在官网上配置 fitView: true 是可以的。 P.S. gitee 地址的官网同步不过去了,现在可以访问这个新的地址,速度非常快,并且都是第一时间更新:https://g6.antv.antgroup.com/

Yanyan-Wang avatar Dec 26 '22 08:12 Yanyan-Wang