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

Adjust force directed 2d graph spacing #184

Merged
merged 2 commits into from
Feb 23, 2024
Merged

Conversation

ghsteff
Copy link
Contributor

@ghsteff ghsteff commented Feb 22, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[x] Other... Please describe: Improvement

What is the new behavior?

Better spacing on forceDirected2d graphs

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

e.g. of 1000 nodes

BEFORE
Screenshot 2024-02-21 at 5 26 13 PM

AFTER
Screenshot 2024-02-21 at 5 25 46 PM

This also affected some medium sized graphs like below. The "before" debatably looks better here tho 😅

BEFORE
image

AFTER
image

@ghsteff ghsteff requested a review from amcdnl February 22, 2024 00:05
@@ -106,12 +113,20 @@ export function forceDirected({
const nodeStrengthAdjustment =
is2d && edges.length > 25 ? nodeStrength * 2 : nodeStrength;

let forceX = d3ForceX(1200 / 2).strength(0.05);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are re-assigning - why not just make if/else to save on init of the object you throw away.

@amcdnl amcdnl merged commit 81c24d4 into master Feb 23, 2024
1 check passed
@amcdnl amcdnl deleted the Adjust-force-directed-spacing branch February 23, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants