How to update dag without re-creation and also minimize layout shifts? #90
Replies: 2 comments 2 replies
-
@coconutlad Tanks for the detailed write up and discussion. Sorry it's taken so long for me to respond. Overall, d3-dag is not well set up for dynamic dags. That was by design to keep things simple, and because without a use case in mind, I didn't want to make design decisions that would harm how it would actually be used. However, I've always wanted to support those use cases. Eventually #79 was posted and that's got us thinking about what dynamic should entail. After a lot of playing around, there was more emphasis on improving the layout than improving how it generated things dynamically. So far I think every dynamic user does exactly what you describe. They recreate the dag, call sugiyama on it again, and update things. I encourage you to read through what's been discussed in #79. It may be of specific interest to read though the stuff on dynadag. I'm generally open to implementing and supporting anything that makes sense. By that I mean, if you can propose an API and what it would do, it should be feasible. dynadag is probably a good place to start. As far as what you're asking about / requesting:
What that means for next steps:
Addressing the things you mentioned in the short term:
|
Beta Was this translation helpful? Give feedback.
-
Sorry for the radio silence! I think I might have said this a few places, but want to make sure my bases are covered. Thanks for doing all this research. I'll be honest in that I've only skimmed dynadag, so I can't comment about the details, but I can't imagine the steps are too much more complicated than the original layout. My feeling is that the best implementation is going to be something separate that supports manual options like, "add node" and "delete node", however your idea is an interesting one. The original design was not for any of the methods to store state, but the idea of caching the previous call and updating accordingly is an interesting way to fit dynamism into the layout, and should work reasonably well. I will say, though, that when I looked back at the code to construct the LP it took a long time for me to figure out what was going on, so best of luck with tweaking it the way you want. If you're having trouble, I'm happy to help dive in. Before I commit too much to this path though, I want to look at dynadag more seriously. Originally I held off because @curiousandy didn't see it as the biggest blocker, and there was an interesting question of why nothing happened to it. That said, it seems worthwhile, so might as well jump in. |
Beta Was this translation helpful? Give feedback.
-
Hi @erikbrinkman,
Hope I'm posting this question in the right place.
I'm using d3-dag for an application where the graph is updated frequently.
It has been very helpful, thank you for creating it and maintaining it so well!
If possible, could you please verify if I'm using d3-dag the right way?
Overview
The app I'm working on displays a DAG to users. They can click on any node and all of the node's children and parents will be added to the graph (if they aren't already in the graph).
In a little more detail:
ConnectOperator
(StratifyOperator
could be used instead if needed)Sugiyama
layout functionThe issue
Now the issue is with the interaction part:
// checks are done to avoid duplicates
Now all of this works fine but I feel like there might be a better way to update the dag without re-creating it. I've tried:
proot
is being used to store the nodes internally (haven't tried editing that because it's not publicly accessible according to typescript)Why?
I'm looking for an alternative way to update because:
Minimal example
Here's a small example which mimics a part of the application:
https://codesandbox.io/s/d3-dag-update-graph-6b68gn?file=/src/index.ts
I can add you as an editor if you'd like.
Would it be possible to update the dag without re-creating it? I'm assuming it is one step towards minimizing layout shifts (pardon me if that's an incorrect relation).
I'm open to modifying my copy of the source code if required to tailor it for the application.
Thanks once again for all your work!
Beta Was this translation helpful? Give feedback.
All reactions