antvis/G6

To get REAL center in graph.zoom you need to use window.innerWidth and window.innerHeight NOT graph.getViewPortCenterPoint() #5091

Radomir-Drukh posted onGitHub

Describe the bug

To get REAL center in graph.zoom you need to use window.innerWidth and window.innerHeight NOT graph.getViewPortCenterPoint()

graph.zoom(1.2, graph.getViewPortCenterPoint()) - WRONG

This call will zoom with move with offset

graph.zoom(1.2, {x: window.innerWidth / 2, y: window.innerHeight / 2} ) - CORRECT

This call will zoom right at the center.

Please state this fact in the documentation

Your Example Website or App

-

Steps to Reproduce the Bug or Issue

1) Create graph that takes up only part of the screen 2) Call graph.zoom(1.2, graph.getViewPortCenterPoint())

Expected behavior

As a user, I expected that graph.zoom(1.2, graph.getViewPortCenterPoint()) will zoom at the center of the camera view but i am seeing strange offset

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome

Additional context

No response


hi @Radomir-Drukh, welcome!

posted by github-actions[bot] over 1 year ago

Hi @Radomir-Drukh, Please star this repo if you find it useful! Thanks :star:! 你好 @Radomir-Drukh。如果该仓库对你有用,可以 star 一下,感谢你的 :star:!

posted by github-actions[bot] over 1 year ago

The implementation of getViewPortCenterPoint is:

<img width="510" alt="image" src="https://github.com/antvis/G6/assets/29593318/222c1c1a-9bb8-481e-a580-b196587aa659">

Which means the API returns the point in rendering coordinate system for the center of canvas DOM. If the graph has initial zoom (1) and not translation, the point of rendering coordinate system is equal to the center point of canvas DOM in number. But after zooming and translating (maybe caused by fitView, fitCenter, mouse wheel, etc.), they are different. Refer to the doc: https://g6.antv.antgroup.com/en/manual/advanced/coordinate-system , where the rendering coordinate system I mentioned before is the pointX/pointY coordinate system in the doc.

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