I was updating my nodeDataArray in each iteration, like self.diagram.model.nodeDataArray = […]
So I replaced it for addNodeDataCollection and now each call takes the same time to complete! This allows me to build a progress bar, which is great!!
The only problem is: in my diagram, for some reason, when a child node is inside a different batch from its parent, they never get “linked”, resulting in multiple nodes that act like root, even when all timeout calls are done. Do you know what I could be doing wrong?
My timeout function looks like this:
`
var quantity = 1000;
var allPositions = this.simulationMonth.listSimulationPositions();
self.diagram.model.nodeDataArray = [];
var i = 0;
function includeOnView(diagram, allPositions){
console.log('iteration: ' + (i++));
var start = diagram.model.nodeDataArray.length;
var end = start + quantity;
diagram.model.addNodeDataCollection(allPositions.slice(start, end > allPositions.length ? allPositions.length : end));
if (allPositions.length > diagram.model.nodeDataArray.length){
setTimeout(function(){
includeOnView(diagram, allPositions);
}, 900);
}
}
includeOnView(self.diagram, allPositions);
self.diagram.startTransaction('centralize');
self.diagram.alignDocument(go.Spot.Center, go.Spot.Center);
self.diagram.commitTransaction('centralize');
and some configurations:
`
layout: {
treeStyle: go.TreeLayout.StyleLastParents,
arrangement: go.TreeLayout.ArrangementHorizontal,
sorting: go.TreeLayout.SortingAscending,
nodeSpacing: 100,angle: 90,
layerSpacing: 35,
alternateAngle: 90,
alternateLayerSpacing: 35,
alternateAlignment: go.TreeLayout.AlignmentBus
},
diagram: {
validCycle: go.Diagram.CycleDestinationTree,
maxSelectionCount: 1,
allowZoom: true,
allowDelete: false,
scrollMode: go.Diagram.InfiniteScroll,
'animationManager.isEnabled': false,
'toolManager.hoverDelay': 100,
'undoManager.isEnabled': false
}
`