|
|
@ -501,6 +501,8 @@ Network.prototype.setData = function(data, disableStart) { |
|
|
|
if (disableStart === undefined) { |
|
|
|
disableStart = false; |
|
|
|
} |
|
|
|
// we set initializing to true to ensure that the hierarchical layout is not performed until both nodes and edges are added.
|
|
|
|
this.initializing = true; |
|
|
|
|
|
|
|
if (data && data.dot && (data.nodes || data.edges)) { |
|
|
|
throw new SyntaxError('Data must contain either parameter "dot" or ' + |
|
|
@ -509,7 +511,6 @@ Network.prototype.setData = function(data, disableStart) { |
|
|
|
|
|
|
|
// set options
|
|
|
|
this.setOptions(data && data.options); |
|
|
|
|
|
|
|
// set all data
|
|
|
|
if (data && data.dot) { |
|
|
|
// parse DOT file
|
|
|
@ -531,15 +532,21 @@ Network.prototype.setData = function(data, disableStart) { |
|
|
|
this._setNodes(data && data.nodes); |
|
|
|
this._setEdges(data && data.edges); |
|
|
|
} |
|
|
|
|
|
|
|
this._putDataInSector(); |
|
|
|
if (!disableStart) { |
|
|
|
// find a stable position or start animating to a stable position
|
|
|
|
if (this.constants.stabilize) { |
|
|
|
this._stabilize(); |
|
|
|
if (disableStart == false) { |
|
|
|
if (this.constants.hierarchicalLayout.enabled == true) { |
|
|
|
this._resetLevels(); |
|
|
|
this._setupHierarchicalLayout(); |
|
|
|
} |
|
|
|
else { |
|
|
|
// find a stable position or start animating to a stable position
|
|
|
|
if (this.constants.stabilize) { |
|
|
|
this._stabilize(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.start(); |
|
|
|
} |
|
|
|
this.initializing = false; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -681,7 +688,6 @@ Network.prototype.setOptions = function (options) { |
|
|
|
this.setSize(this.constants.width, this.constants.height); |
|
|
|
this.moving = true; |
|
|
|
this.start(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -1348,6 +1354,7 @@ Network.prototype._addNodes = function(ids) { |
|
|
|
} |
|
|
|
this.moving = true; |
|
|
|
} |
|
|
|
|
|
|
|
this._updateNodeIndexList(); |
|
|
|
if (this.constants.hierarchicalLayout.enabled == true && this.initializing == false) { |
|
|
|
this._resetLevels(); |
|
|
@ -1481,15 +1488,14 @@ Network.prototype._addEdges = function (ids) { |
|
|
|
var data = edgesData.get(id, {"showInternalIds" : true}); |
|
|
|
edges[id] = new Edge(data, this, this.constants); |
|
|
|
} |
|
|
|
|
|
|
|
this.moving = true; |
|
|
|
this._updateValueRange(edges); |
|
|
|
this._createBezierNodes(); |
|
|
|
this._updateCalculationNodes(); |
|
|
|
if (this.constants.hierarchicalLayout.enabled == true && this.initializing == false) { |
|
|
|
this._resetLevels(); |
|
|
|
this._setupHierarchicalLayout(); |
|
|
|
} |
|
|
|
this._updateCalculationNodes(); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -2242,7 +2248,7 @@ Network.prototype.focusOnNode = function (nodeId, zoomLevel) { |
|
|
|
this.redraw(); |
|
|
|
} |
|
|
|
else { |
|
|
|
console.log("This nodeId cannot be found.") |
|
|
|
console.log("This nodeId cannot be found."); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|