Skip to content

Commit

Permalink
[frontend] Disable forces when adding a new entity on Grouping Graph (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwendoline-FAVRE-FELIX committed Sep 24, 2024
1 parent 2adb475 commit 9c768ee
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,30 @@ class GroupingKnowledgeGraphComponent extends Component {

async handleAddEntity(stixCoreObject) {
if (R.map((n) => n.id, this.graphObjects).includes(stixCoreObject.id)) return;

this.graph.current.d3Force('link').distance(0);
this.graph.current.d3Force('charge').strength(0);
const currentPositions = R.indexBy(
R.prop('id'),
R.map((n) => ({ id: n.id, x: n.fx, y: n.fy }), this.graphData.nodes),
);

this.graphObjects = [...this.graphObjects, stixCoreObject];
this.graphData = buildGraphData(
this.graphObjects,
decodeGraphData(this.props.grouping.graph_data),
this.props.t,
);

this.graphData.nodes.forEach((node) => {
if (currentPositions[node.id]) {
// eslint-disable-next-line no-param-reassign
node.fx = currentPositions[node.id].x;
// eslint-disable-next-line no-param-reassign
node.fy = currentPositions[node.id].y;
}
});

await this.resetAllFilters();
const selectedTimeRangeInterval = computeTimeRangeInterval(
this.graphObjects,
Expand All @@ -544,6 +562,7 @@ class GroupingKnowledgeGraphComponent extends Component {
},
() => {
setTimeout(() => this.handleZoomToFit(), 1500);
this.forceUpdate();
},
);
}
Expand Down

0 comments on commit 9c768ee

Please sign in to comment.