Big Diagram are loading slow?

We have a custom class for Link and temporary link(CustomLinkingTool) to compute the straight line. This causing the diagram to load too slow and some times browser is hanging. I was thinking that because of custom Link.ComputePoint(), the diagram computing the points for the loading link’s.

My Doubt’s?

  1. Is there any way to cancel computing Link.Computepoints() at load time of diagram?
  2. And also I am looking for initializing all the listener’s, custom classes link after the custom dragging, linking, and so after diagram is loaded in canvas. Is there any way to do it?

Just to clarify: if you replace the custom class used in your link template(s) with go.Link, then the performance for loading and interacting with the diagram is good again, yes?

First, if I were you, I would rewrite your override of Link.computePoints to be efficient.

If that is theoretically not possible, then I would conditionalize its behavior to be fast until a certain state change had happened. But I cannot tell right now what would be best for your situation.

Yes, After changing to go.Link the diagram performance is quite good.

I am also planning to rewrite the Link.ComputePoints in efficient way. Can you suggest me things I need to be careful while overriding computePoints.

That is hard to say.

If you are only concerned about load-time performance, you could conditionalize computePoints to check a flag which is set by an “InitialLayoutCompleted” DiagramEvent listener.

I have some doubts in Link.Points?
I am using Link.routing as AvoidNodes and which contains 6 points and I am trying to calculate straight line if the nodes are in same axis.

  1. Can I have more/less than 6 point’s
  2. Is it possible to replace those 6 points with new points. If so, I tried to replace the point’s but I am facing issue on replacing Why?
  3. Can I maintain 2 points at end’s and remaining 4 point’s at middle for straight line?.

If routing is AvoidsNodes, there can be an unlimited number of points in the route, because there can be an unlimited number of turns the route has to take. However the routing algorithm does return a shortest route with the fewest turns.

Yes, you can call the base method and then fiddle with the resulting route. And yes, it is commonplace for custom routing to keep the one or two end points at each end of the standard link route.

The default behavior of Link.computePoints is quite complex, because it handles so many different combinations of properties on the Link as well as on the connected ports/nodes, as well as when there is only one or zero connected ports.

Are you sure you want to override computePoints? What is it that you are trying to accomplish that cannot be done normally?

Mainly for making the link straight. Using AvoidNodes it’s hard to have straight between two nodes like this:

And also for drawing unconnected straight line from the node in Avoidnodes rotuting.

The purpose of AvoidsNodes routing is not only to “avoid crossing over nodes” but to also provide an orthogonal path. So if the fromSpot and the toSpot do not line up with exactly the same X or Y point in document coordinates, a turn is required.

If you want to avoid small “jags”, could you move the nodes to be aligned to a grid? However that gets more difficult or impossible if you have multiple ports on a node, especially if the distance between ports does not factor evenly into the positions/sizes of the nodes.

Yes. As you told, In our scenario we have multiple ports to the nodes nearly 8 ports. Yes it’s really hard to maintain the fromspot and tospot in same x axis for those nodes.

Do you really need to have logically and physically distinct ports?

If not, another possibility is to just try to connect to the sides of the whole node (which I assume is rectangular).

Consider, for example, the custom routing done by a number of Link subclasses that are in the samples. They vary a bit from each other, but they all intend to route to the nearest point on the side of the node. Look at the link subclass definitions in these samples:

Hi Walter,
InitialLayoutCompleted DiagramEvent listener invoking before the data is coming from Database.
I want to start computation Link.ComputePoints after the diagram data loaded from database to GOJS?.

If you replace the Diagram.model, “InitialLayoutCompleted” is the DiagramEvent that you want.

If you merely modify the model, then “LayoutCompleted” is what you want, except you need to detect the first one after your “load”. “LayoutCompleted” will also happen after any other reason that a layout occurs.