From 5f24f1380dc1896a666df12b68a20363557631ec Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Thu, 25 Jul 2024 11:09:59 +0200 Subject: [PATCH] fix: catch error for all instructions --- .../js/formats/chart/hierarchy/Hierarchy.js | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/js/formats/chart/hierarchy/Hierarchy.js b/src/app/js/formats/chart/hierarchy/Hierarchy.js index d85804825..ed2b44a2f 100644 --- a/src/app/js/formats/chart/hierarchy/Hierarchy.js +++ b/src/app/js/formats/chart/hierarchy/Hierarchy.js @@ -148,6 +148,21 @@ class Hierarchy extends PureComponent { this.update(); } + let current = this.divContainer.current; + let gBbox = this.g().node().getBBox(); + + if ( + current.clientWidth / gBbox.width < + current.clientHeight / gBbox.height + ) { + this.initialPosition.scale = current.clientWidth / gBbox.width; + } else { + this.initialPosition.scale = + current.clientHeight / gBbox.height; + } + + this.initialPosition.scale = this.initialPosition.scale * 0.8; + this.centerGraphClick(); } catch (error) { const { p: polyglot } = this.props; this.tooltip() @@ -162,21 +177,7 @@ class Hierarchy extends PureComponent { ); } - let current = this.divContainer.current; - let gBbox = this.g().node().getBBox(); - - if ( - current.clientWidth / gBbox.width < - current.clientHeight / gBbox.height - ) { - this.initialPosition.scale = current.clientWidth / gBbox.width; - } else { - this.initialPosition.scale = - current.clientHeight / gBbox.height; - } - this.initialPosition.scale = this.initialPosition.scale * 0.8; - this.centerGraphClick(); } }