Browse Source

fixed bug where loading hierarchical data after initalization crashes network

v3_develop
Alex de Mulder 10 years ago
parent
commit
eb438156b7
4 changed files with 24765 additions and 24944 deletions
  1. +1
    -0
      HISTORY.md
  2. +24747
    -24933
      dist/vis.js
  3. +1
    -1
      dist/vis.min.css
  4. +16
    -10
      lib/network/Network.js

+ 1
- 0
HISTORY.md View File

@ -35,6 +35,7 @@ http://visjs.org
- Fixed page scroll event not being blocked when moving around in Network
using arrow keys.
- Fixed an initial rendering before the graph has been stabilized.
- Fixed bug where loading hierarchical data after initialization crashed network.
### Graph2D

+ 24747
- 24933
dist/vis.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/vis.min.css
File diff suppressed because it is too large
View File


+ 16
- 10
lib/network/Network.js View File

@ -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.");
}
};

Loading…
Cancel
Save