Node distance

I have 2 node AED and COUNTRY
often the distance of the knots is too big

and often the distance is short. I want to always keep a short distance

thanks for your help !

I assume you are talking about the distance between nodes.

Are you using ForceDirectedLayout? That assumes that there are Links between the Nodes to counteract the repulsive electrical forces.

When there are no links, the electrical charges cause nodes to move far enough apart until the forces are considered insignificant.

You could either decrease the ForceDirectedLayout.defaultElectricalCharge or decrease the ForceDirectedLayout.infinityDistance. Or maybe increase the ForceDirectedLayout.defaultGravitationalMass.

Thanks !
How can i refrech diagram viewport or
refreach diagram without reload diagram.model

Why would you need to? It should always be up-to-date. Unless perhaps you are not making changes within a transaction?

All changes to models or model data or to GraphObjects should be perfomed within a transaction. Use Diagram.commit or Model.commit for convenience.

I use ForceDirectedLayout

First : i select 2 node, it is ok.

Second : i select several node, it is ok

Third : i reselect 2 node. i think the diagram keep last size. this problem
appear when i select several node before.

I don’t understand the situation. Where did those additional nodes come from? What are the values of Diagram.documentBounds before and after each layout?

my Diagram.documentBounds in image.
it is same value all time.

Your last screenshot shows a Rect that has a position of -5,-5 and a size of 10x10. That does not make sense at all, because all of the earlier screenshots showed at least two Nodes covering an area greater than 10x10.

Could you provide a stand-alone reproducible case that we can talk about and experiment with? That would let us give you some suggestions.

Hello a sample code is on this link


Entity Relationship

check box and click on the SELECT button. the diagram is ok

Click on the button ‘ALL’

When i click on SELECT button i don’t have a first image.
I have this

How can i fixe this for have a first Image

You have a TwoWay Binding on Node.location, so each time there is a layout, each node data object remembers the location of the node.

Furthermore you have modified the ForceDirectedLayout.infinityDistance so that nodes don’t have any forces on each other if they are more than 100 units apart. So once the nodes have their locations, they remain there.

It works :)
my problem was Node.location