Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redraw connections after moving nodes #438

Open
beard7 opened this issue Sep 24, 2024 · 2 comments
Open

Redraw connections after moving nodes #438

beard7 opened this issue Sep 24, 2024 · 2 comments

Comments

@beard7
Copy link

beard7 commented Sep 24, 2024

I've used the Drag and Drop community sample (https://stackblitz.com/edit/js-bmyjfc?file=index.html) to enable re-organisation of the chart and it's working well.

Using a very minor modification, it's possible to drag nodes to anywhere in the chart -- is there a way that connecting lines could be redrawn after moving a node to a random position (it's probably a big ask!).

@bumbeishvili
Copy link
Owner

bumbeishvili commented Sep 24, 2024

Yes, definitely don't plan to work on that.

If you want to take a swing at it,

you will need to get connectionsWrapper from the chart state and then manually update positions as you are drawing

Here is how it looks within org chart code

.attr("d", (d) => {
const xo = attrs.layoutBindings[attrs.layout].linkJoinX({ x: x0, y: y0, width, height });
const yo = attrs.layoutBindings[attrs.layout].linkJoinY({ x: x0, y: y0, width, height });
const o = { x: xo, y: yo };
return attrs.layoutBindings[attrs.layout].diagonal(o, o, null, { sy: attrs.linkYOffset });
});

So, code will look like this

const state = chart.getState();
const wrapper = state.connectionsWrapper;
const connections = wrapper.selectAll('.connection')

// Then plug following code into drag event
connections
 .attr("d", (d) => {
       return `customly positioned path taking the linked sample into account`
  });

@beard7
Copy link
Author

beard7 commented Nov 28, 2024

Apologies for the lack of response... I've been switched to focus on other matters, but thanks for the tip. I'll give it a go when I get chance. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants