react-d3-graph icon indicating copy to clipboard operation
react-d3-graph copied to clipboard

Bendable links

Open zofbanach opened this issue 6 years ago • 4 comments

Hi Daniel, is it possible to draw links that are bended? So when I have a graph where all of the nodes have defined x and y, links and also have defined positions, where they break? I couldn't find it in the documentation.

example

Or would it be possible to draw some links with arrows and some without arrows (and have not visible nodes between them) to implement that?

Sorry if the question was asked somewhere, I couldn't find any information about that.

zofbanach avatar Sep 16 '20 12:09 zofbanach

You can make curved links using link.type configuration, however I'm not sure if that is exactly what you are looking for.

const config = {
    link: {
        type: 'CURVE_SMOOTH'
    }
}

More info here: https://danielcaldas.github.io/react-d3-graph/docs/index.html#link-type

terahn avatar Sep 20 '20 20:09 terahn

@terahn Thank you for your answer. I've seen this option but what I actually meant is bending/breaking the line is defined places. Something like defining link this way: { source: "node1" target: "node2" type: "STRAIGHT" breakPoints: [ [x:12, y:10], [x:15, y: 9] ] }

Or, if that's impossible, implementing it by drawing links with hidden nodes between them and without arrows. That's where the second question comes from: can I draw arrows only for some links?

zofbanach avatar Sep 22 '20 06:09 zofbanach

@danielcaldas I'd like to tackle this issue, Add an option for a link to receive array of breakPoints, then make buildLinkPathDefinition draw the link according to its source node (x, y) and its target node (x, y) and the breakPoints, this will work perfectly on static graph.

But when moving nodes around is possible we have two options (I can think of...):

  1. When a node moves across the graph, draw it again with its source node (x, y) and its target node (x, y) and the breakPoints received.
  2. When a node moves across the graph, call a callback from the user, that receives its new/unchanged source node (x, y), and its new/unchanged target node (x, y) of all the links connected to the moved node. (3. Support both of those options)

What do you think? I guess I want to start with a PR that receives breakPoints for a link, without implementing the callback behavior mentioned, waiting for you input on this :)

lironhl avatar Oct 08 '20 10:10 lironhl

Hey, @lironhl let's move this discussion over to the Pull Request. I would also like to ask you to elaborate more on what issues you're facing while dragging nodes.

danielcaldas avatar Oct 13 '20 11:10 danielcaldas