Closed df5118 closed 2 years ago
@df5118 thanks for reaching out.
d3Force
is a component method, not prop. That means it needs to be accessed via component refs, as in this example: https://github.com/vasturiano/react-force-graph/blob/master/example/collision-detection/index.html#L34
Thank you for the response. That is very clear now :-)
So to do this completely for React:
npm i d3 d3-force
npm i @types/d3 --save-dev
import * as d3 from "d3-force";
...
ForceGraph()
...
.d3Force('link', d3.forceLink()
.distance(60))
...
Sources:
How to make different links of different size ? #107,
thank you Vasco Asturiano,
https://github.com/vasturiano/react-force-graph/issues/107#issuecomment-517140737
Cannot find module d3 or its corresponding type declarations #2362,
thank you Moritz Klack,
https://github.com/xyflow/xyflow/issues/2362#issuecomment-1214879301
How do you customize the d3 link strength as a function of the links and nodes counts ? (d3 v4),
thank you duncdrum,
https://stackoverflow.com/a/39389846
Importing d3 in react JS component file,
thank you marielle,
https://stackoverflow.com/a/64906943
I know this has been has been brought up in #107 and #127, but I was wondering if anyone could clarify what was meant in the answer. It was said you simply do
.d3Force('link').distance(link => /* your code */)
or, as was mentioned in the question of #107 use:this.fg.d3Force
What is 'this' supposed to refer to, and what has method .d3Force that is being accessed? Thanks for any advice you can give :-)