Skip to content
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

重新绘制画布, 修改数据 #1413

Closed
cheng-xiaofeng opened this issue Oct 11, 2021 · 11 comments
Closed

重新绘制画布, 修改数据 #1413

cheng-xiaofeng opened this issue Oct 11, 2021 · 11 comments

Comments

@cheng-xiaofeng
Copy link

image
我想在修改右边的时候, 画布中的数据也实时更新, 我调用了cell.setData(), 但是画布中的数据只修改了一次, 第二次就不变了, 这该怎么做

@NewByVector
Copy link
Contributor

setData 方法需要每次传入的对象不一致,是不是传入了同一个对象?

@cheng-xiaofeng
Copy link
Author

setData 方法需要每次传入的对象不一致,是不是传入了同一个对象?

image
这样写的, fieldJson是数据组, 每一项就是一条数据

@NewByVector
Copy link
Contributor

抽出一个简单 demo 看下?

@cheng-xiaofeng
Copy link
Author

抽出一个简单 demo 看下?

image
就这个跟上一个截图

@NewByVector
Copy link
Contributor

搞个 codesanbox 看下,你这样给代码看不出问题

@cheng-xiaofeng
Copy link
Author

搞个 codesanbox 看下,你这样给代码看不出问题

我尽可能的多一点代码(没弄过codesanbox, 尴尬)
image
image
image

@cheng-xiaofeng
Copy link
Author

搞个 codesanbox 看下,你这样给代码看不出问题

调用setData之后, 数据都没有进入node节点这个自定义的组件中(react组件)

@cheng-xiaofeng
Copy link
Author

搞个 codesanbox 看下,你这样给代码看不出问题

setData()时,如果改变的是数组,比如 [{a: 1}], 改为[{a: 2}], 是不是监听不到这种变化. 我试了一下添加了一个元素, 就重新渲染了

@NewByVector
Copy link
Contributor

应该是 fiedlJson 是同一个对象造成的。试试

import { ObjectExt } from '@antv/x6'
node.setData(ObjectExt.cloneDeep(xxx))

@komagic
Copy link

komagic commented Aug 24, 2022

onEdgeLabelRendered 的组件 setData后画面不会变,只有拖动了才能刷新。。

graph 的update 函数去哪里了

@x6-bot
Copy link
Contributor

x6-bot bot commented Aug 25, 2023

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 x6-bot bot locked as resolved and limited conversation to collaborators Aug 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants