All assets loaded event

I’m setting up a diagram with a large model, where most of the nodes have their own svg used as a picture. The load time is noticeable and I’d like to hide the diagram until it’s complete. Is there a callback or event I can use for that? I’m aware of succesFunc for a singular picture but as the model is variable I never know how many pictures will be loaded or how many will be repeated.

That is what the “InitialLayoutCompleted” DiagramEvent is for.

That’s what I initially assumed, but there’s still around half a second delay before the images are actually displayed after InitialLayoutCompleted was fired.

Oh, you mean the SVG that you want to show is in “files”, and there is delay in loading those files?

You could call Diagram | GoJS API and supply the callback option function, because a call to makeImageData will try to wait until all images have loaded before running. Note: this functionality is new in 2.0.

Sorry, we don’t expose any asset management capabilities like that. You could remember how many images you have loaded so that you can count them down in a succesFunc, if you first add extra work to the Picture.source data binding to remember how many:

var picturesToLoad = 0;

...

new go.Binding("source", "src", function(s) {
  picturesToLoad++;
  return "images/" + s + ".png";
})),

...

// later picturesToLoad--; in the success func, then check for 0 again.

I think that will work.

Otherwise, you can use the callback to makeImageData as Walter says.