Adjusting link force depending on group? #374
-
Hi, I'm kind of lost in both these and d3 docs — but assume I have link objects with a group component; how do I make the attraction force depend on this? I would expect something like .d3Force('link', link => link.group === 'weakLink' ? 0.1 : 1) but I fail to find the exact syntax needed. Thanks and Happy 2025 to everyone! |
Beta Was this translation helpful? Give feedback.
Answered by
vasturiano
Jan 7, 2025
Replies: 1 comment
-
@vzakharov thanks for reaching out. A given force has usually multiple parameters that could be configured based on some data parameter. I'm not sure which parameter of the link force you want to update but assuming it is the strength, you could do something like this: .d3Force('link').strength(link => link.group === 'weakLink' ? 0.1 : 1) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
vzakharov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vzakharov thanks for reaching out.
A given force has usually multiple parameters that could be configured based on some data parameter. I'm not sure which parameter of the link force you want to update but assuming it is the strength, you could do something like this: