Prevent a node being moved up and down

Hi,

Is there any way to prevent a node from moving up and down, only allow them to be moved left and right? For example, in Genogram, I want to keep the node on the same y-axis level as where has been first placed.

I couldn’t find the properties for that in the documentation, is there a way to do it? Or is there any function I would need to override?

Thanks.

Heh, I actually discover a way to do that myself. My method is to override the commitNodes function. Out of curiosity, is there any other cleaner way to do this other than overriding functions?

You can use NaN as the Y value for the Node.minLocation and Node.maxLocation.

Example: the “lane” Groups in Swim Lanes (vertical)

I have realised this only works if you drag the nodes manually. The thing is Genogram would for some reason auto shuffle the Y axis if a marriage is given. So let say if I want to add a consanguineous relationship between two nodes:

It will become like this:

As you can see, the diamond node has moved downwards a level, which is wrong. How can I make it stay on the same level as it is?

Sorry, but when parents marry their own children or when someone becomes their own grandparent the GenogramLayout might not do what you want.

We’re working on a new GenogramLayout that I hope will produce better results.

Why? There is no way we can restrict one node when it is been assigned a position x, y? What will be the complication if I have to modify prototype.commitNodes?

Let say for example, if spouseB is been given a (x, y) position, restrict the movement of Y axis.

If you are overriding a LayeredDigraphLayout method (remember not to modify its prototoype) you can certainly change the behavior, in this case by changing the location of the node(s) to be where you want them to be. However I don’t think that that would be easy in this general, because you need to worry about other nodes already being where you want a particular node to be.

Setting isLayoutPositioned: false handles a similar case for me.

Not sure what you are hoping it to look like for the consanguineous relationships, but routing: go.Link.AvoidsNodes does appear (I only tested a few samples) to be respected even without layout positioning.

The consanguineous relationship we are handling is a bit tricker. Because:

  1. We need to be able to add nodes and links in real-time, so ideally, every time a new element is added, the nodes would reshuffle itself to make a neater pedigree.

  2. A consanguineous relationship needs to have a marriage node like a normal married couple, so that it can attach children to them. Although the first event of adding maybe fine, whenever a new element is added later, Genogram would reposition the nodes. And because that consanguineous relationship is considered a married couple, Genogram would make the two linked nodes a single group, which therefore move one of the linked node below.

Currently we are using our own custom method to achieve consanguineous relationship. Although it does the job, the method is more complex and it is not necessary better.