X6 icon indicating copy to clipboard operation
X6 copied to clipboard

x6 怎么主动刷新页面

Open komagic opened this issue 3 years ago • 7 comments

Describe the bug

x6 怎么主动刷新页面

Your Example Website or App

x6 怎么主动刷新页面

Steps to Reproduce the Bug or Issue

x6 怎么主动刷新页面

Expected behavior

x6 怎么主动刷新页面

Screenshots or Videos

No response

Platform

x6 怎么主动刷新页面

Additional context

x6 怎么主动刷新页面

komagic avatar Aug 26 '22 08:08 komagic

image

我看钉钉群里面的消息。所谓的“刷新”,指的是画布大小自适应吧?

lloydzhou avatar Aug 26 '22 09:08 lloydzhou

主动刷新 graph 的函数,不是大小自适应

rerender graph的,之前api里的update函数都没了

监听 change:data也没了

komagic avatar Aug 28 '22 06:08 komagic

image 这个去哪里了

komagic avatar Aug 28 '22 06:08 komagic

什么场景需要刷新画布呀?resetCells 是否能满足你要求。上面说的 update 方法是官网的错误,其实是更新 scroller 的 updateScroller。

NewByVector avatar Aug 30 '22 12:08 NewByVector

resetcells是可以,但是性能太差,会闪一下。 我就想setData后,数据直接显示更新在图上。不知道为啥react自定义节点监听不到数据变化. 。应该是没有做好数据监听。 数据setData后,要移动一下画板内容,才会显示出来内容。而这个刷新不会闪一下,是我要的,请问移动一下的这个‘刷新’采用的是哪个api

komagic avatar Sep 12 '22 16:09 komagic

node.hasChanged('data') 比较的是什么?比较对象地址就行了,现在变化了监听不到什么情况。新的data 和老的对象完全不==,都触发不了hasChanged true...

komagic avatar Sep 12 '22 16:09 komagic

node.position(x,y)刷新页面的性能都比resetCells好太多

 const {x,y} = node.position();
    node.position(x+1,y);
    node.position(x,y);

komagic avatar Sep 12 '22 16:09 komagic

刚升级到2.0版本,我也遇到了这个修改数据未触发事件的问题,先监听事件

graph.on('edge:change:data',({edge})=> {
        console.log(edge);
})

然后更新数据

cell.setData(newData)

并不会触发

@NewByVector 帮忙看一下

chiangcho avatar Dec 05 '22 13:12 chiangcho

刚升级到2.0版本,我也遇到了这个修改数据未触发事件的问题,先监听事件

graph.on('edge:change:data',({edge})=> {
        console.log(edge);
})

然后更新数据

cell.setData(newData)

并不会触发

@NewByVector 帮忙看一下

我也遇到类似问题了,试了下,在setData加一个时间戳(或者其他不固定的值)后,就可以触发change:data了; node.setData({ ...node.data, timestamp: Date.now(), // 添加后才可触发 change:data 事件 })

tianjinhao avatar Dec 26 '22 03:12 tianjinhao

@komagic @chiangcho @tianjinhao data 的改变需要设置新的对象,也就是对象引用完全不一致,才会触发 chagne:data。

NewByVector avatar Feb 01 '23 01:02 NewByVector

@komagic 局部更新比如位置,可以直接使用对应的 api,如果所有元素更新,使用 resetCells

NewByVector avatar Feb 01 '23 01:02 NewByVector

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

x6-bot[bot] avatar Feb 02 '24 01:02 x6-bot[bot]