-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
实现保存定位信息,界面缩放到指定center 位置一直有偏差 #6093
Comments
麻烦使用规范的 markdown 代码块或者提供复现地址 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug / 问题描述
实现保存center和zoom 用zoomTo 还原定位 出现位置偏差
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
***body
保存
刷新
修改定位1
***body
***script
var graph =''
const data = {
// 点集
nodes: [
{
id: 'node1', // String,该节点存在则必须,节点的唯一标识
x: 100, // Number,可选,节点位置的 x 值
y: 200, // Number,可选,节点位置的 y 值
},
{
id: 'node2', // String,该节点存在则必须,节点的唯一标识
x: 300, // Number,可选,节点位置的 x 值
y: 200, // Number,可选,节点位置的 y 值
},
],
// 边集
edges: [
{
source: 'node1', // String,必须,起始点 id
target: 'node2', // String,必须,目标点 id
},
],
};
init()
function init(){
if(graph){
graph.destroy()
graph=null
}
graph = new G6.Graph({
modes: {
default: ['drag-canvas', 'zoom-canvas', 'drag-node'],
},
container: 'container', // String | HTMLElement,必须,在 Step 1 中创建的容器 id 或容器本身
width: 800, // Number,必须,图的宽度
height: 500, // Number,必须,图的高度
});
graph.data(data); // 读取 Step 2 中的数据源到图上
graph.render(); // 渲染图
// console.log('getViewPortCenterPoint0',graph.getViewPortCenterPoint())
// console.log('getGraphCenterPoint0',graph.getGraphCenterPoint())
let position=localStorage.getItem('position')
if(position){
let pp=JSON.parse(position)
let client= graph.getClientByPoint(pp.center.x, pp.center.y)
let client1= graph.getCanvasByPoint(pp.center.x, pp.center.y)
console.log('pp',pp)
console.log('client',client)
console.log('client1',client1)
graph.zoomTo(pp.zoom,client1)
***script
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome
Additional context / 补充说明
No response
The text was updated successfully, but these errors were encountered: