-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add ability to change graph forces via UI #10755
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
Conversation
|
Added commit 10305d6 to fix the failing lint test |
|
You ran the CICD workflow and it failed on a lint test, so I added an extra commit to the PR already to resolve that issue |
|
@xyhp915 is anything needed from me to allow one of the logseq team to review this PR? I spent a lot of time on it, and on providing a clear PR. I haven't heard anything for a month. It's not particularly encouraging towards contributing to the project.. Could you or @tiensonqin communicate what I can expect? |
10305d6 to
28ef22b
Compare
tiensonqin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mp-v2 Thanks for looking into all the discussions related to graph view and your amazing work on those exciting enhancements! 👍
I QAed it on my local graph and it works as you described, I'll merge this PR and open another PR to adjust ui/slider to trigger on-change when the mouse is released.
| (.distanceMax (if (> nodes-count 500) 4000 600)) | ||
| ;; The minimum distance between nodes over which this force is considered. | ||
| ;; A minimum distance establishes an upper bound on the strength of the force between two nearby nodes, avoiding instability. | ||
| (.distanceMin 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| (.force "y" (-> (forceY 0) (.strength 0.02))) | ||
| (.force "center" (forceCenter)) | ||
| (.velocityDecay 0.8)) | ||
| ;; The decay factor is akin to atmospheric friction; after the application of any forces during a tick, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
|
@tiensonqin thanks for the reply and for the review - happy to see it worked well enough to merge already! |
|
Great to see this in the 0.10.6 release! And good effort with that slider mouse release efficiency improvement |
This MR adds the ability to change graph forces in the graph view, under a new dropdown menu item called "Forces"
This resolves requests for a customisable/better graph algorithm:
This should also resolve some a number of user issues related to the graph layout being messy/not being very useful:
Users resorted to manually dragging nodes to where they want them to be, and then requesting that the graph does not reset/re-render each time you click back to it. The ability to change graph forces means users can now customise the default force values, thus the default layout of their graph, using the config.edn default parameters. This indirectly resolves the requests to have a layout-persistant graph option:
To not overload the number of options, although more are possible using the same structure, I implemented the key ones:
The graph is reactive to the sliders, and the graph forces can be reset back to defaults using the "Reset forces" button, similar to "Reset graph" for the n-hops slider.
Force values, in general, default to the same value they were previously, so that the default experience is the same as it was before. Exceptions;
link distance has been reduced from 180 to 70. This makes graphs significantly cleaner
the velocity decay when dragging nodes has been reduced from 0.8 to 0.5 to allow the graph to better converge on a clean layout. This (partially) resolves issues like:
https://discuss.logseq.com/t/better-graph-make-sure-the-edges-of-graph-do-not-cross-like-obsidian/16862
https://discuss.logseq.com/t/how-the-graph-view-could-improve-creativity/5579/2?u=mapping_world
https://discuss.logseq.com/t/graph-view-nodes-should-move-with-their-parents/1929
I set the sliders to have a stepsize proportional to the value size (e.g. 5, 10 or 100), to prevent too much rendering of large graphs. It would be more efficient to have the graph render on slider release (instead of on value change), however I would need someone more familiar with Clojure to assist with this.
Cheers,
mp-v2
Here is my personal graph using the master branch:

Here is the same graph with default forces in this branch (with lower velocity decay, allowing better convergence on a clean solution):

Now with adjusted forces based on personal preference. These changes are persistant, even when changing to note pages and returning to the graph view:

Examples from a large graph are much more exciting, but some examples below show options now available
Small link distance:

Large link distance:

Default negative charge (repulsion) changed to positive (gravity) causes orphan pages to come to the centre:

A positive charge strength, and long link distance, will group chuild nodes together from one node:
