question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow `d3.layout.force().chargeDistance` to take a function

See original GitHub issue

A number of settings on the d3.layout.force() object are dynamic, like linkStrength, linkDistance and charge. They take a function, so the value can be different for each node or link.

This seems to not be the case for chargeDistance. Is there a reason for this? It would come in handy for me at the moment. I have a number of isolated groups of nodes with their own gravity and enforced bounds, but still with occasional inter-group links. Having the chargeDistance be limited to the group size of each particular node would help both performance and visible behavior.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mbostockcommented, Apr 26, 2016

Composable forces have been implemented in d3-force for D3 4.0.

0reactions
mbostockcommented, Apr 26, 2016

The charge is a global (many-body) force, so the charge distance can’t be customized on a per-node basis (or per pair of nodes). However, it would be possible to compose multiple charge forces that affect different subsets of nodes, such that each charge force is local to the subset. See d3/d3-force#2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Force Layout - D3 wiki
A flexible force-directed graph layout implementation using position Verlet integration to allow simple constraints. For more on physical simulations, ...
Read more >
Forcing Functions: Inside D3.v4 forces and layout transitions
force.strength() allows us to set up an accessor for calculating the force strength for each node. However, instead of running that accessor ...
Read more >
D3 Force layout - D3 in Depth
D3's force layout uses physics based rules to position visual elements. This article shows how to use D3's force layout and how to...
Read more >
[Solved]-D3.JS theta in force layout-d3.js - appsloveworld.com
I found the easiest way to learn and experiment with how the forces affect the graph was to make temporary sliders that you...
Read more >
D3.js 3 documentation - DevDocs
Layouts - derive secondary data for positioning elements; Geography - project spherical coordinates, latitude & longitude math; Geometry - ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found