Skip to content

Commit

Permalink
Adding a parameter in config to be able to disable link force (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninklopp authored and danielcaldas committed Jan 11, 2020
1 parent e98c481 commit b328f6f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ const graph = {
- 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`)
- `d3.linkLength` **[number][96]** the length of each link from the center of the nodes it joins. (optional, default `100`)
- `d3.linkStrength` **[number][96]** [see d3-force link.strength][107]
- `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`)
<br/> (optional, default `1`)
- `node` **[Object][99]** node object is explained in next section. ⬇️<h2 id="config-node"><a href="#config-node">#</a> Node level configurations</h2>
- `node.color` **[string][98]** 🔍🔍🔍 this is the color that will be applied to the node if no **color property**
Expand Down Expand Up @@ -1204,9 +1205,11 @@ components.
},
...
}

```
```
- `linkCallbacks` **[Array][100]&lt;[Function][101]>** array of callbacks for used defined event handler for link interactions.
- `config` **[Object][99]** an object containing rd3g consumer defined configurations [config][118] for the graph.
- `highlightedNode` **[string][98]** this value contains a string that represents the some currently highlighted node.
Expand Down
1 change: 1 addition & 0 deletions sandbox/data/static/static.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ module.exports = {
d3: {
gravity: -400,
linkLength: 180,
disableLinkForce: true,
},
};
6 changes: 4 additions & 2 deletions src/components/graph/Graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ export default class Graph extends React.Component {
* @returns {undefined}
*/
_graphBindD3ToReactComponent() {
this.state.simulation.nodes(this.state.d3Nodes).on("tick", this._tick);
this._graphLinkForceConfig();
if (!this.state.config.d3.disableLinkForce) {
this.state.simulation.nodes(this.state.d3Nodes).on("tick", this._tick);
this._graphLinkForceConfig();
}
this._graphNodeDragConfig();
}

Expand Down
1 change: 1 addition & 0 deletions src/components/graph/graph.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export default {
gravity: -100,
linkLength: 100,
linkStrength: 1,
disableLinkForce: false,
},
node: {
color: "#d3d3d3",
Expand Down

0 comments on commit b328f6f

Please sign in to comment.