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

graph.dispose() not working as expected #3751

Closed
tmarsik42 opened this issue Jul 7, 2023 · 4 comments
Closed

graph.dispose() not working as expected #3751

tmarsik42 opened this issue Jul 7, 2023 · 4 comments
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions

Comments

@tmarsik42
Copy link

tmarsik42 commented Jul 7, 2023

问题描述

Follow up from this discussions thread:
#3723

I've been thinking about how to reproduce the behaviour in the most simple way possible and I chose the approach of just displaying how graph.dispose() doesn't really dispose anything for me, which results in behaviour I described in the discussion. (tldr; dispose isnt disposing)

I made a repo on stackblitz, the link is below. Most important logic is in GraphX6.svelte file, test1.json and test2.json are elk processed graph definitions. You can probably ignore the rest.

重现链接

https://stackblitz.com/edit/sveltejs-kit-template-default-z3os2x?file=src%2Froutes%2Ftest1.json

重现步骤

Step 1: Copy contents of test1.json (contains 3 nodes and 2 edges) and paste to textarea. Graph with 3 nodes and 2 edges, albeit ugly, should display.
Step 2: Delete contents of textarea and click dispose button. Graph looks cleared.
Step 3: Copy contents of test2.json (contains 2 nodes and 1 edge) and paste again. It displays the same graph like in step 1 (3 nodes, 2 edges).
Step 4. Doublecheck - refresh, copy and paste test2.json. Shows 2 nodes and 1 edge.

预期行为

Is this a bug or am I misunderstanding what graph.dispose() does? I'd expect it would trash the whole graph instance and every relation to it. I am even reinstancing the graph but it doesn't help either.

平台

  • 操作系统: [macOS]
  • 网页浏览器: [Google Chrome]
  • X6 版本: [2.11.1 ...]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@x6-bot
Copy link
Contributor

x6-bot bot commented Jul 7, 2023

👋 @tmarsik42

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@NewByVector
Copy link
Contributor

When I enter the contents of test2, I print $cell before graph.resetCells and find that it is an array of length 13, so your previous calculation is wrong. Not a problem with graph.dispose.

@NewByVector NewByVector added the type: discussion 讨论 Usage questions, guidance, and other discussions label Jul 10, 2023
@tmarsik42
Copy link
Author

tmarsik42 commented Jul 10, 2023

I print $cell before graph.resetCells and find that it is an array of length 13

Thanks to your comment I've been able to break out of my debugging block. It indeed isn't a problem with graph.dispose(). I've failed to realize $cells need to be cleared in between renders because I remade it to a svelte store which is inherently global. This appears to be in contrast with the localized example I used as a reference (https://x6.antv.vision/en/examples/showcase/practices#elk).

After correctly disposing of $cells store too, I no longer get duplicated or merged graphs.

Thank you for your guidance

@x6-bot
Copy link
Contributor

x6-bot bot commented Jul 10, 2024

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 Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions
Projects
None yet
Development

No branches or pull requests

2 participants