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

See link direction #28

Open
pvalin opened this issue Jan 15, 2020 · 1 comment
Open

See link direction #28

pvalin opened this issue Jan 15, 2020 · 1 comment

Comments

@pvalin
Copy link

pvalin commented Jan 15, 2020

Hi,

Not really an issue rather an enhancement (or probably I'm hopeless and it's already practicable ^^). Is it possible to show the direction of a link with an arrow or a moving particle like vasturiano's 3d-force-graph :

Thanks for your work in any case! :)

@lordnox
Copy link
Contributor

lordnox commented Jan 17, 2020

Hi,

When iterating through a link list you should know what node you are working with.

const linkDirection = (node: Node, incoming: boolean) =>
  node.links.filter(link => node.id === (incoming ? link.toId : link.fromId))

const incomingLinks = linkDirection(node, true)
const outgoingLinks = linkDirection(node, false)

With link.toId and link.fromId you can figure out the direction.

The other possibility is to use the link.data property to save the "direction"

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