Browse Source

fixed clustering issue #1050

flowchartTest
Alex de Mulder 9 years ago
parent
commit
296a457d31
6 changed files with 5809 additions and 4089 deletions
  1. +13
    -0
      HISTORY.md
  2. +4061
    -4036
      dist/vis.js
  3. +27
    -7
      lib/network/modules/Clustering.js
  4. +13
    -16
      lib/network/modules/View.js
  5. +1694
    -30
      test/networkTest.html
  6. +1
    -0
      test/network_unittests.html

+ 13
- 0
HISTORY.md View File

@ -4,6 +4,11 @@ http://visjs.org
## not-yet-released, version 4.3.1-SNAPSHOT
### General
- Documentation now has breadcrums. Thanks @felixhayashi!
### Graph3d
- Fixed #970: Implemented options `dataColor`, `axisColor`, and `gridColor`.
@ -28,6 +33,9 @@ http://visjs.org
- Added blurEdge and hoverEdge events.
- Added labelHighlightBold option to edges and nodes.
- Added getOptionsFromConfigurator method.
- Fixed extra edges in clustering.
- Fixed cleaning up of clustering edges on declustering.
- Made fit() method only look at visible nodes to get the range.
### Graph2d
@ -35,6 +43,11 @@ http://visjs.org
- Fixed bug where 0 axis was always in the automatically fitted range.
- Added drawPoints.onRender. Thanks @mschallar!
### Timeline
- Fixed cleaning up of items in subgroups, thanks @ChenMachluf!
- Improved error notification with groups, thanks @skinkie!
## 2015-06-16, version 4.3.0

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


+ 27
- 7
lib/network/modules/Clustering.js View File

@ -275,7 +275,7 @@ class ClusterEngine {
clonedOptions.from = fromId;
clonedOptions.to = toId;
clonedOptions.id = 'clusterEdge:' + util.randomUUID();
newEdges.push(this.body.functions.createEdge(clonedOptions))
newEdges.push(this.body.functions.createEdge(clonedOptions));
}
}
}
@ -321,8 +321,11 @@ class ClusterEngine {
// get clusterproperties based on childNodes
let childEdgesOptions = [];
for (let edgeId in childEdgesObj) {
let clonedOptions = this._cloneOptions(childEdgesObj[edgeId], 'edge');
childEdgesOptions.push(clonedOptions);
// these cluster edges will be removed on creation of the cluster.
if (edgeId.substr(0,12) !== "clusterEdge:") {
let clonedOptions = this._cloneOptions(childEdgesObj[edgeId], 'edge');
childEdgesOptions.push(clonedOptions);
}
}
clusterNodeProperties = options.processProperties(clusterNodeProperties, childNodesOptions, childEdgesOptions);
@ -376,8 +379,18 @@ class ClusterEngine {
if (childEdgesObj.hasOwnProperty(edgeId)) {
if (this.body.edges[edgeId] !== undefined) {
let edge = this.body.edges[edgeId];
edge.togglePhysics(false);
edge.options.hidden = true;
// if the edge is a clusterEdge, we delete it. The opening of the clusters will restore these edges when required.
if (edgeId.substr(0,12) === "clusterEdge:") {
edge.edgeType.cleanup();
// this removes the edge from node.edges, which is why edgeIds is formed
edge.disconnect();
delete childEdgesObj[edgeId];
delete this.body.edges[edgeId];
}
else {
edge.togglePhysics(false);
edge.options.hidden = true;
}
}
}
}
@ -522,7 +535,7 @@ class ClusterEngine {
if (containedEdges.hasOwnProperty(edgeId)) {
let edge = containedEdges[edgeId];
// if this edge was a temporary edge and it's connected nodes do not exist anymore, we remove it from the data
if (this.body.nodes[edge.fromId] === undefined || this.body.nodes[edge.toId] === undefined) {
if (this.body.nodes[edge.fromId] === undefined || this.body.nodes[edge.toId] === undefined || edge.toId == clusterNodeId || edge.fromId == clusterNodeId) {
edge.edgeType.cleanup();
// this removes the edge from node.edges, which is why edgeIds is formed
edge.disconnect();
@ -566,9 +579,16 @@ class ClusterEngine {
}
}
// remove all temporary edges
// remove all temporary edges, make an array of ids so we don't remove from the list we're iterating over.
let removeIds = [];
for (let i = 0; i < clusterNode.edges.length; i++) {
let edgeId = clusterNode.edges[i].id;
removeIds.push(edgeId);
}
// actually removing the edges
for (let i = 0; i < removeIds.length; i++) {
let edgeId = removeIds[i];
this.body.edges[edgeId].edgeType.cleanup();
// this removes the edge from node.edges, which is why edgeIds is formed
this.body.edges[edgeId].disconnect();

+ 13
- 16
lib/network/modules/View.js View File

@ -53,23 +53,20 @@ class View {
}
}
else {
for (var nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
node = this.body.nodes[nodeId];
if (minX > (node.shape.boundingBox.left)) {
minX = node.shape.boundingBox.left;
}
if (maxX < (node.shape.boundingBox.right)) {
maxX = node.shape.boundingBox.right;
}
if (minY > (node.shape.boundingBox.top)) {
minY = node.shape.boundingBox.top;
} // top is negative, bottom is positive
if (maxY < (node.shape.boundingBox.bottom)) {
maxY = node.shape.boundingBox.bottom;
} // top is negative, bottom is positive
for (var i = 0; i < this.body.nodeIndices.length; i++) {
node = this.body.nodes[this.body.nodeIndices[i]];
if (minX > (node.shape.boundingBox.left)) {
minX = node.shape.boundingBox.left;
}
if (maxX < (node.shape.boundingBox.right)) {
maxX = node.shape.boundingBox.right;
}
if (minY > (node.shape.boundingBox.top)) {
minY = node.shape.boundingBox.top;
} // top is negative, bottom is positive
if (maxY < (node.shape.boundingBox.bottom)) {
maxY = node.shape.boundingBox.bottom;
} // top is negative, bottom is positive
}
}

+ 1694
- 30
test/networkTest.html
File diff suppressed because it is too large
View File


+ 1
- 0
test/network_unittests.html View File

@ -144,6 +144,7 @@
{name:"moveTo", arguments: [{position:{x:0,y:0}}]},
{name:"focus", arguments: [1]},
{name:"releaseNode", arguments: null},
{name:"getOptionsFromConfigurator", arguments: null},
]
drawQuick();

Loading…
Cancel
Save