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

Any idea to implement Arrow on Links. #73

Closed
Naveenraj006 opened this issue Jan 4, 2020 · 3 comments
Closed

Any idea to implement Arrow on Links. #73

Naveenraj006 opened this issue Jan 4, 2020 · 3 comments

Comments

@Naveenraj006
Copy link

I want to implement an Arrow at the edge of links. Can you give me an idea or hack to implement this?

@ColemanCollins
Copy link

ColemanCollins commented Jan 16, 2020

You can make a custom Link component that uses an SVG <marker> to drop an arrowhead on the end of a link. The challenge with this is that the way the current link path drawing/curve generation works, it actually flips the start/end points depending on the spatial relationship of the nodes rather than their directed graph relationship. Which means you'll also have to modify the generateCurvePath utility to not do that, because it makes the arrowheads pretty useless.

Here's a gist where I've been playing with this; it's okay for a fairly strict left-to-right and top-to-bottom graph (which is my use case) but you'll need to figure out curve paths that work for your node/link relationships. Hopefully this is enough to get you moving on your own solution: https://gist.github.com/ColemanCollins/541b5987c312e02beb1c10b323db4933

@Naveenraj006
Copy link
Author

Screenshot 2020-01-20 at 11 24 23 AM

Yes, the curve path differs from the actual start and stop node. So, I wrote a hack with SVG text to display an arrow at the center of the line.

@Naveenraj006
Copy link
Author

You can make a custom Link component that uses an SVG <marker> to drop an arrowhead on the end of a link. The challenge with this is that the way the current link path drawing/curve generation works, it actually flips the start/end points depending on the spatial relationship of the nodes rather than their directed graph relationship. Which means you'll also have to modify the generateCurvePath utility to not do that, because it makes the arrowheads pretty useless.

Here's a gist where I've been playing with this; it's okay for a fairly strict left-to-right and top-to-bottom graph (which is my use case) but you'll need to figure out curve paths that work for your node/link relationships. Hopefully this is enough to get you moving on your own solution: https://gist.github.com/ColemanCollins/541b5987c312e02beb1c10b323db4933

Thank you coleman.

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