How to move the full tree of orgchart js balkan using javascript?

145 Views Asked by At

I would like to move the tree of Balkan orgchart js using javascript.

(https://balkan.app/OrgChartJS/Docs/GettingStarted)

Ideally with button right , left , top , bottom for each moves. The tree can move with hold and move of the mouse, but I can not find ways to move it using javascript command only.

Any help would be welcome

Thanks

2

There are 2 best solutions below

3
Plamen Peshev On

You can use the new moveStart and moveEnd methods from the latest version

Here is a Code demo

Clear your browser cache and test the Code above

Disclaimer: I'm a developer at BALKAN App

0
FredyK On

The way to make it work was done with using a timer with setTimeout

 moveGraphUp() {
    console.log("Moving up");
   
    this.chart.moveStart({
            up: true 
        });
    setTimeout(() => {  console.log("ending move"); this.chart.moveEnd(); }, 500); 
    
    console.log("Moved up");
}

Note: We have 2 screens open and the idea is to triggered it on both side so that the graph is mirrored similarly on both side. And we don't want to use mouse over as the mirroring wouldn't be synchronised well.

Ideally We need a moveStart with a number of steps to move. (Click only one click => run with javascript which would be update simultaneously on my 2 screens ) but the timer is working too.