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

How to conditionally change linkLineDash between nodes #335

Open
jacoblindgren opened this issue Oct 12, 2023 · 1 comment
Open

How to conditionally change linkLineDash between nodes #335

jacoblindgren opened this issue Oct 12, 2023 · 1 comment

Comments

@jacoblindgren
Copy link

I haven't been able to figure out a way to style links between nodes conditionally, on a node-by-node basis, the same way it's possible to conditionally style the nodes themselves (i.e. #331). I'm trying something like this:

.linkLineDash(node => {
      if (node.type === "output") {
        return [1,15];
      } else {
        return [1,1];
      }
    })

with a JSON structure like this:

{
"id": "MW7OHHLuUO9qRuG6",
"title": "Example1",
"type": "output"
},
{
"id": "K21lZ3Bx8sg5aIzW",
"title": "Example2",
"type": "place"
}

with no luck. Is .linkLineDash() the wrong place to do this?

@vasturiano
Copy link
Owner

@jacoblindgren the parameter you get in the linkLineDash method is a link object, not a node. So yes you can style the links conditionally this way, but your logic needs to be based on the link, f.e.:

.linkLineDash(link => {
      if (link.source.type === "output") {
        return [1,15];
      } else {
        return [1,1];
      }
    })

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