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

Add support for "smart" link routing #54

Closed
dmitrygalperin opened this issue Oct 16, 2019 · 12 comments · Fixed by #89
Closed

Add support for "smart" link routing #54

dmitrygalperin opened this issue Oct 16, 2019 · 12 comments · Fixed by #89

Comments

@dmitrygalperin
Copy link

Are there any plans to implement a "smart" link routing prop, where instead of taking the shortest path between two ports, links will avoid collision with other nodes to give the chart a neater appearance? Example attached
nodes

@MrBlenny
Copy link
Owner

I'm unlikely to have time to work on such a feature. Certainly not for at least a few months. Happy to accept PRs :)

@dmitrygalperin
Copy link
Author

@MrBlenny Thanks, I'll see if I can put together a PR.

@dmitrygalperin
Copy link
Author

I have a fork at https://github.com/dmitrygalperin/react-flow-chart/tree/master that implements this via config={{ smartRouting: true }}

If anyone would like to take a look or offer suggestions/concerns before I submit a PR, please feel free.

Some concerns:

Pathfinding is expensive so performance is slower. I am limiting pathfinding to only nodes that are in view as well as scaling down the resolution of the pathfinding matrix. As a fallback to when a path cannot be found, I create a direct right angle link between the ports.

I also feel that the pathfinding can be tweaked to make the paths neater, though I'm not sure exactly how, especially with performance in mind.

@MrBlenny
Copy link
Owner

@dmitrygalperin is that ready to be a PR?

@Pagebakers
Copy link

@dmitrygalperin @MrBlenny Any news? Would really like this to be merged!

@Pagebakers
Copy link

Pagebakers commented Jan 10, 2020

I just merged this in to my project, but I don't see any difference with smartRouting enabled. @dmitrygalperin is this the latest version you shared?

It's working quite well actually :)

@mchaledg19
Copy link

config={{ smartRouting: true }} doesn't work on my project. Any news for smart link?
<FlowChart chart={chart} callbacks={stateActions} config={{ smartRouting: true, // disabledPorts: [], validateLink: ({ linkId, fromNodeId, fromPortId, toNodeId, toPortId, chart }) => { if (chart.nodes[fromNodeId].type === chart.nodes[toNodeId].type) return false; return true; } }} Components={{ CanvasOuter: CanvasOuterCustom, NodeInner: NodeInnerCustom, Port: PortCustom, Link: props => <LinkCustom {...props} stateActions={stateActions} /> }} />

@Pagebakers
Copy link

The problem has probably to do with your custom port/link components. Remove those and it should work :)

@dmitrygalperin
Copy link
Author

@MrBlenny @Pagebakers

Apologies, I'm just now getting time to get back to this. I think it's ready for a PR

@mchaledg19
Copy link

mchaledg19 commented Feb 21, 2020

any update? if this is already merged?
@MrBlenny

@hyusetiawan
Copy link

@MrBlenny ping, would love to get the smart routing merged :)

@MrBlenny
Copy link
Owner

MrBlenny commented Feb 26, 2020 via email

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

Successfully merging a pull request may close this issue.

5 participants