diff --git a/opencti-platform/opencti-front/src/private/components/analyses/groupings/GroupingKnowledgeGraph.jsx b/opencti-platform/opencti-front/src/private/components/analyses/groupings/GroupingKnowledgeGraph.jsx index 247cde6aa1d3b..f880724559545 100644 --- a/opencti-platform/opencti-front/src/private/components/analyses/groupings/GroupingKnowledgeGraph.jsx +++ b/opencti-platform/opencti-front/src/private/components/analyses/groupings/GroupingKnowledgeGraph.jsx @@ -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, @@ -544,6 +562,7 @@ class GroupingKnowledgeGraphComponent extends Component { }, () => { setTimeout(() => this.handleZoomToFit(), 1500); + this.forceUpdate(); }, ); }