I have a layered digraph with ~350 nodes. It was taking about 3 secs to load previously. However when I overwrote assignLayers and commitLayers my performance dropped to more like 20 secs. I am not sure if this is because of added complexity to the internal layout algorithms, or if I inadvertently caused the computations to run multiple times. Any ideas?
MyLayout.prototype.assignLayers = function() {
go.LayeredDigraphLayout.prototype.assignLayers.call(this);
var it = this.network.vertexes.iterator;
while (it.next()) {
var v = it.value;
if (v.node !== null) {
var lay = v.node.data.level;
if (typeof lay === "number" && lay >= 0) {
v.layer = lay;
}
}
}
};
MyLayout.prototype.commitLayers = function(layerRects, offset) {
// update the background object holding the visual "bands"
var bands = this.diagram.findPartForKey("_BANDS");
if (bands) {
var model = this.diagram.model;
bands.location = this.arrangementOrigin.copy().add(offset);
// make each band visible or not, depending on whether there is a layer for it
for (var it = bands.elements; it.next();) {
var idx = it.key;
var elt = it.value; // the item panel representing a band
elt.visible = idx < layerRects.length;
}
// set the bounds of each band via data binding of the "bounds" property
var arr = bands.data.itemArray;
for (var i = 0; i < layerRects.length; i++) {
var itemdata = arr[i];
if (itemdata) {
model.setDataProperty(itemdata, "bounds", layerRects[i]);
}
}
}
};