Skip to content

Commit b328f6f

Browse files
antoninkloppdanielcaldas
authored andcommitted
Adding a parameter in config to be able to disable link force (#278)
1 parent e98c481 commit b328f6f

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

docs/DOCUMENTATION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ const graph = {
362362
- If value is negative, nodes will repel each other. Most of the times this is what we want, so nodes don"t overlap. (optional, default `-100`)
363363
- `d3.linkLength` **[number][96]** the length of each link from the center of the nodes it joins. (optional, default `100`)
364364
- `d3.linkStrength` **[number][96]** [see d3-force link.strength][107]
365+
- `d3.disableLinkForce` **[number][96]** when setting this value to true, the nodes will stay at the position chosen by the user, and no other d3 simulation will be done. (optional, default `false`)
365366
<br/> (optional, default `1`)
366367
- `node` **[Object][99]** node object is explained in next section. ⬇️<h2 id="config-node"><a href="#config-node">#</a> Node level configurations</h2>
367368
- `node.color` **[string][98]** 🔍🔍🔍 this is the color that will be applied to the node if no **color property**
@@ -1204,9 +1205,11 @@ components.
12041205
},
12051206
...
12061207
}
1208+
12071209
```
12081210
12091211
```
1212+
12101213
- `linkCallbacks` **[Array][100]&lt;[Function][101]>** array of callbacks for used defined event handler for link interactions.
12111214
- `config` **[Object][99]** an object containing rd3g consumer defined configurations [config][118] for the graph.
12121215
- `highlightedNode` **[string][98]** this value contains a string that represents the some currently highlighted node.

sandbox/data/static/static.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ module.exports = {
2323
d3: {
2424
gravity: -400,
2525
linkLength: 180,
26+
disableLinkForce: true,
2627
},
2728
};

src/components/graph/Graph.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ export default class Graph extends React.Component {
183183
* @returns {undefined}
184184
*/
185185
_graphBindD3ToReactComponent() {
186-
this.state.simulation.nodes(this.state.d3Nodes).on("tick", this._tick);
187-
this._graphLinkForceConfig();
186+
if (!this.state.config.d3.disableLinkForce) {
187+
this.state.simulation.nodes(this.state.d3Nodes).on("tick", this._tick);
188+
this._graphLinkForceConfig();
189+
}
188190
this._graphNodeDragConfig();
189191
}
190192

src/components/graph/graph.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export default {
237237
gravity: -100,
238238
linkLength: 100,
239239
linkStrength: 1,
240+
disableLinkForce: false,
240241
},
241242
node: {
242243
color: "#d3d3d3",

0 commit comments

Comments
 (0)